Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8758723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:37:13+00:00 2026-06-13T14:37:13+00:00

I have a requirement of transforming a huge XML document into multiple HTML documents.

  • 0

I have a requirement of transforming a huge XML document into multiple HTML documents.
The XML is as follows:

<society>
  <party_members>
    <member id="1" first_name="" last_name="O'Brien">
      <ministry_id>1</ministry_id>
      <ministry_id>3</ministry_id>
    </member>
    <member id="2" first_name="Julia" last_name="">
      <ministry_id>2</ministry_id>
    </member>
    <member id="3" first_name="Winston" last_name="Smith">
      <ministry_id>1</ministry_id>
    </member>
  </party_members>
  <ministries>
    <ministry>
      <id>1</id>
      <short_title>Minitrue</short_title>
      <long_title>Ministry of truth</long_title>
      <concerns>News, entertainment,education and arts </concerns>      
    </ministry>
    <ministry>
      <id>2</id>
      <short_title>Minipax</short_title>
      <long_title>Ministry of Peace</long_title>
      <concerns>War</concerns>
    </ministry>
    <ministry>
      <id>3</id>
      <short_title>Minilove</short_title>
      <long_title>Ministry of Love</long_title>
      <concerns>Dissidents</concerns>      
    </ministry>
  </ministries>
</society>

Where potential number of party members can be quite large – millions, and number of ministries is small, around 300-400. For each of the party member there should be an output HTML with following content:

<html>  
  <body>
    <h2>Party member: Winston Smith</h2>
    <h3>Works in:</h3>
    <div class="ministry">
      <h4>Ministry of truth</h4> - Minitrue
      <h5>Ministry of truth <i>concerns</i> itself with <i>News, entertainment,education and arts</i></h5>  
    </div>
  </body>
</html>

The number of output documents should == number of party members.

I’m now struggling with XSLT, but can’t get it to work.

Please help me decide if XSLT is a good tool for this job, if it is, hint me as if how to implement it, what XSLT constructs should be used, etc.

Of course I could simply write mini transformation in a procedural language, but I’m looking for a ‘apply transformation template‘ approach, rather than procedural parsing and modification to be able to hand the template to other users for further modifications (CSS, formatting etc).

I’m using ruby + nokogiri(which is a set of bindings to libxslt), but it is possible to use any language.

If XSTL is a bad fit for this task, what other instruments can be used here, provided I must transform ~1M of users in several minutes with small memory consumption?

Additional benefit would be to be able to parallelize the processing.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:37:14+00:00Added an answer on June 13, 2026 at 2:37 pm

    In order to achieve this result (producing several html files) you definitely need XSLT 2.0. I suggest the usage of Saxon for that.

    Here you have a sample XSL which produces what you need (creates a single html file for each member, all inside a “html” folder in your sytem’s root, and gives back a report of what it created). You’ll probably need to tweek it a little bit to fit your needs.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output omit-xml-declaration="yes" indent="yes" method="html"/>
        <xsl:variable name="target-dir" select="'/html'"/>
        <xsl:key name="ministries" match="/society/ministries/ministry" use="id"/>
        <xsl:strip-space elements="*"/>
        <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
        <xsl:template match="/">
            <Output>
                <xsl:apply-templates select="*"/>
            </Output>
        </xsl:template>
        <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
        <xsl:template match="*">
            <xsl:apply-templates select="*"/>
        </xsl:template>
        <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
        <xsl:template match="member">
            <Html path="{concat($target-dir,'/',@id,'.html')}">
                <xsl:result-document href="{concat($target-dir,'/',@id,'.html')}">
                    <html>
                      <body>
                        <h2><xsl:value-of select="concat('Party member: ',@first_name,' ',@last_name)"/></h2>
                        <h3>Works in:</h3>
                        <xsl:apply-templates select="ministry_id"/>
                      </body>
                    </html>
                </xsl:result-document>
            </Html>
        </xsl:template>
        <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
        <xsl:template match="ministry_id">
        <xsl:variable name="ministry" select="key('ministries',.)"/>
        <div class="ministry">
            <h4><xsl:value-of select="$ministry/long_title"/></h4> - <xsl:value-of select="$ministry/short_title"/>
            <h5><xsl:value-of select="$ministry/long_title"/> <i>concerns</i> itself with <i><xsl:value-of select="$ministry/concerns"/></i></h5>
        </div>
        </xsl:template>
    </xsl:stylesheet>
    

    And here you have a sample output:

    <html>
       <body>
          <h2>Party member:  O'Brien</h2>
          <h3>Works in:</h3>
          <div class="ministry">
             <h4>Ministry of truth</h4> - Minitrue
             <h5>Ministry of truth<i>concerns</i> itself with <i>News, entertainment,education and arts </i></h5>
          </div>
          <div class="ministry">
             <h4>Ministry of Love</h4> - Minilove
             <h5>Ministry of Love<i>concerns</i> itself with <i>Dissidents</i></h5>
          </div>
       </body>
    </html>
    

    Regarding performance, several millions is a big amount of data. I guess that xsl will be enough for it, but I’m afraid you’ll need to give it a try before knowing for sure.

    I hope this helps you!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have requirement of specifying web part connections in onet.xml. So when site is
I have requirement to not to use html event handler. So I am trying
Hi: We have requirement to setup alert on a document library (alert to defined
I have requirement where I have input Html like this - <col name=col1>Text1</col> <col
I have requirement where some times I would like to load children as well
I have requirement to disable copy/paste/cut operations on a textbox. For this purpose I
I have requirement, wherein I have to calculate totals for cash and credit cards
I have requirement like, suppose I have a 'property' table which has 'ListingKey' field
I have requirement as following like showing ABPeoplePickerNavigationController in tabbar based application. I researched
I have requirement to get Facebook friends list with their images. How can I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.