|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] How to perse the whole source document
Hi all,
Hi Jeni!
I have the source xml (file 1) like this:
<article>
<section name="S01">
<para seq="P01.01"> aaa </para>
<para seq="P01.01"> bbb </para>
<para seq="P01.02"> xxx </para>
<para seq="P01.02"> yyy </para>
<section name="S01.01">
<para seq="P01.01.01"> mmm </para>
<para seq="P01.01.01"> nnn </para>
<para seq="P01.02.01"> ppp </para>
<para seq="P01.02.01"> rrrr </para>
</section>
</section>
</article>
XML file 2:
<TableName>
<RecordName>
<P01.01>
<path> path1 </path>
<cat> category1 </cat>
<P01.01>
</RecordName>
<RecordName>
<P01.01.01>
<path> path2 </path>
<cat> category2 </cat>
<P01.01.01>
</RecordName>
</TableName>
My XSL look like this:
<?xml version="1.0" encoding='ISO-8859-1' ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
-->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="section">
<sid>
<xsl:apply-templates select="*[1]" mode="merge" />
</sid>
</xsl:template>
<xsl:template match="*" mode="merge">
<xsl:copy-of select="." />
<xsl:apply-templates select="following-sibling::*[1]" mode="merge" />
</xsl:template>
<xsl:template match="para" mode="merge">
<xsl:variable name="as" select="@name" />
<text name="{@name}">
<xsl:apply-templates select="." mode="content" />
<xsl:copy-of select="document('doc2.xml')
/TableName/RecordName[normalize-space(name) =
$as]
/*[not(self::name)]" />
</text>
<xsl:apply-templates mode="merge"
select="following-sibling::para[@name != current()/@name][1]" />
</xsl:template>
<xsl:template match="para" mode="content">
<xsl:copy-of select="node()" />
<xsl:text>
</xsl:text>
<xsl:apply-templates mode="content"
select="following-sibling::*[1][@name = current()/@name]" />
</xsl:template>
</xsl:stylesheet>
The out put comes like this:
<article>
<sid>
<text name="P01.01">aaa bbb
<path>path1</path>
<cat>cattegory1</cat>
</text>
</sid>
</article>
Now my question is why does not it perse the whole document? In other words
I expect my resulting xml as to be:
<article>
<sid>
<text name="P01.01">aaa bbb
<path>path1</path>
<cat>cattegory1</cat>
</text>
<sid>
<text name="P01.01.01">mmm nnn
<path>path2</path>
<category>cattegory2</category>
</text>
</sid>
</sid>
</article>
But I do not get it....
Please help. Thank you all in advance.
Regards,
Mo
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








