[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Combining xml file manipulation into one xsl

Subject: Combining xml file manipulation into one xsl
From: "Karen Dunstall" <kdunstall@xxxxxxxxxxxxxxx>
Date: Thu, 2 Oct 2003 09:04:13 +1000
combining xml files
Hi

I want to combine the workings of two xsl files into one.  I don't think this should be hard, but I seem to be having a total no-brain day.  Can anyone help me?

I take one xml file (index.xml), convert it to a format I want, then combine it with another, existing file (tblMasterFile.xml) of the same format and weed out the duplicates.  I can do each of these individually, but right now have to save the xml files in between.  That is:

I start with Convert.xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes"/>
  <xsl:template match="/">
     <CodeLibrary>
    <xsl:for-each select="doxygenindex/compound">
      <File>
      <xsl:apply-templates select="."/>
      </File>
    </xsl:for-each>
    </CodeLibrary>
  </xsl:template>
  <xsl:template match="doxygenindex/compound">
    <Name><xsl:value-of select="name"/></Name>
    <Type><xsl:value-of select="@kind"/></Type>
    <BriefDescription/>
    <SourceFileName><xsl:value-of select="@refid"/></SourceFileName>
    <IgnoreFlag>77</IgnoreFlag>  
  </xsl:template>
</xsl:stylesheet>

And I save the result as a new xml file - newIndex.xml

Then I do a second transformation in a second xsl file (Merge.xsl) using the newly created xml file (newIndex.xml), plus another xml file (tblMasterFile) to combine these two files, eliminating any duplicates.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="/">
    <CodeLibrary>
      <xsl:for-each select="document('tblMasterFile.xml')/CodeLibrary/File | document('newIndex.xml')/CodeLibrary/File[not(Name=document('tblMasterFile.xml')/CodeLibrary/File/Name)]">
        <xsl:sort select="Name"/>
        <File>
          <Name>
            <xsl:value-of select="./Name"/>
          </Name>
          <Type><xsl:value-of select="./Type"/></Type>
          <BriefDescription><xsl:value-of select="./BriefDescription"/></BriefDescription>
          <SourceFileName><xsl:value-of select="./SourceFileName"/></SourceFileName>
          <IgnoreFlag><xsl:value-of select="./IgnoreFlag"/></IgnoreFlag>
        </File>
      </xsl:for-each>
    </CodeLibrary>
  </xsl:template>
</xsl:stylesheet>


My xml is as follows:

Index.xml  -- a huge file, most of which I ignore for this exercise.

<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<doxygenindex>
  <compound refid="classCMembers" kind="class">
    <name>CMembers</name>
    <member refid="classCMembers" kind="function">
      <name>WriteXML</name>
    </member>
    <member refid="classCMembers" kind="function">
      <name>WriteValidXMLList</name>
    </member>
    <member refid="classCMembers" kind="function">
      <name>Retrieve</name>
    </member>
    <member refid="classCMembers" kind="function">
      <name>UpdateStatus</name>
    </member>
    <member refid="classCMembers" kind="function">
      <name>AddressChange</name>
    </member>
  </compound>
  <compound refid="cShares_8cpp" kind="file">
    <name>cShares.cpp</name>
    <member refid="cShares_8cpp" kind="function">
      <name>GetServiceAccountName</name>
    </member>
    <member refid="cShares_8cpp" kind="function">
      <name>GetSharesAccountNumber</name>
    </member>
    <member refid="cShares_8cpp" kind="function">
      <name>processSharePurchasePlan</name>
    </member>
    <member refid="cShares_8cpp" kind="function">
      <name>processNonRenouncableRightsIssue</name>
    </member>
  </compound>
</doxygenindex>


newIndex.xml and tblMasterFile.xml, both of which are the same format.

<CodeLibrary>
  <File>
    <Name>CMembers</Name>
    <Type>class</Type>
    <BriefDescription></BriefDescription>
    <SourceFileName>classCMembers</SourceFileName>
    <IgnoreFlag>77</IgnoreFlag>
  </File>
  <File>
    <Name>cShares.cpp</Name>
    <Type>file</Type>
    <BriefDescription>Define the classes for share manipulation.</BriefDescription>
    <SourceFileName>cShares_8cpp</SourceFileName>
    <IgnoreFlag>0</IgnoreFlag>
  </File>
</CodeLibrary>

Thanks
Karen

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.