Hi,
I am having significant issues numbering consecutive nodes in XSLT V1.
My source XML document looks like (dots to represent rather large
sub-trees:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<aggregator>
<data_source type="Memory Data Source" name="Page Data">
... ...
</data_source>
<data_source type="Sql Server Database Data Source" name="SQL
Content">
<PageContent>
<MDD_Site_Content>
<content_id>88aba99f-cddd-4bad-9fd6-da6a10313f4c</content_id>
<page_webpart_id>e7bf951e-0561-41a3-9aa0-6f9f9b96cb53</page_webpart_id>
<unique_content_id>e647fb4d-4345-45e2-a3c7-7d8ae557557d</unique_content_
id>
<MDD_Site>
... ...
</MDD_Site>
</MDD_Site_Content>
<MDD_Dealership_Content>
... ...
</MDD_Dealership_Content>
</PageContent>
</data_source>
</aggregator>
My output document needs to look like:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<aggregator>
<data_source type="Memory Data Source" name="Page Data">
... ...
</data_source>
<data_source type="Sql Server Database Data Source" name="SQL
Content">
<PageContent id="1">
<MDD_Site_Content id="2">
<content_id
id="3">>88aba99f-cddd-4bad-9fd6-da6a10313f4c</content_id>
<page_webpart_id
id="4">e7bf951e-0561-41a3-9aa0-6f9f9b96cb53</page_webpart_id>
<unique_content_id
id="5">e647fb4d-4345-45e2-a3c7-7d8ae557557d</unique_content_id>
<MDD_Site id="6">
... ...
</MDD_Site>
</MDD_Site_Content>
<MDD_Dealership_Content id="20">
... ...
</MDD_Dealership_Content>
</PageContent>
</data_source>
</aggregator>
I have therefore tried to use <xsl:number> and a template that looks a
bit like:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="PageContent//node()">
<xsl:copy>
<xsl:attribute name="id"><xsl:number
count="node()"/></xsl:attribute>
<xsl:apply-templates
select="PageContent//node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
I am having real issues iterating through all the descendants of the
PageContent node and applying the same template to them (irrespective of
numbering!)
Any help appreciated.
Mark
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--