S
super.raddish
Greetings one and all,
I have a single source XML file and I am parsing the "records" within
it into separate XML files using xsl:result-document. All that works
fine. I am using the Saxon engine and I am supplying the .Transform()
with a Target File path which it is using to create an empty file (as
it is currently unused). So I end up with, say, 50 new XML flies and 1
empty XML file at the path of the Target File
<stylesheet>
<!-- context of Target File -->
<for-each loop>
<xsl:result-document href="file(n)">
<!-- context of New File (n) -->
<!-- Write output to New File ... -->
</xsl:result-document>
</for-each loop>
</stylesheet>
What I want to be able to do is write to the Target File context from
within the <xsl:result-document> context.
<stylesheet>
<!-- context of Target File -->
<for-each loop>
<xsl:result-document href="file(n)">
<!-- context of New File (n) -->
<!-- Write output to New File ... -->
<!-- Write message to Target File ... -->
</xsl:result-document>
</for-each loop>
</stylesheet>
The XSL file I am using (as an example) is below. Does anyone have any
suggestions or is this simply impossible. I have thought about using
<xsl:message> and capturing the output but I want this to be fully
self contained in the XSLT if it can be.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xslaram name="outputPath" />
<xsl:variable name="dataMapping"
select="document('DataMapping.xml')" />
<xsl:key name="oceans" match="mapsection[@name='oceans']/
entry" use="@clientname" />
<xsl:template match="/">
<xsl:for-each select="main/datarecord">
<xsl:result-document href="file:///{$outputPath}-
{count(ancestor::node()|preceding::*)}.xml" >
<updateRecord>
<family><xsl:value-of select="species" /></family>
<genus><xsl:value-of select="subspecies" /></genus>
<habitat>
<xsl:variable name="clientHabitat" select="location" />
<xsl:for-each select="$dataMapping">
<xsl:value-of select="key('oceans', $clientHabitat)/
@internalname"/>
</xsl:for-each>
</habitat>
<fullname><xsl:value-of select="name" /></fullname>
</updateRecord>
</xsl:result-document>
</xsl:for-each>
</xsl:stylesheet>
Any help or advice greatly appreciated
Al
I have a single source XML file and I am parsing the "records" within
it into separate XML files using xsl:result-document. All that works
fine. I am using the Saxon engine and I am supplying the .Transform()
with a Target File path which it is using to create an empty file (as
it is currently unused). So I end up with, say, 50 new XML flies and 1
empty XML file at the path of the Target File
<stylesheet>
<!-- context of Target File -->
<for-each loop>
<xsl:result-document href="file(n)">
<!-- context of New File (n) -->
<!-- Write output to New File ... -->
</xsl:result-document>
</for-each loop>
</stylesheet>
What I want to be able to do is write to the Target File context from
within the <xsl:result-document> context.
<stylesheet>
<!-- context of Target File -->
<for-each loop>
<xsl:result-document href="file(n)">
<!-- context of New File (n) -->
<!-- Write output to New File ... -->
<!-- Write message to Target File ... -->
</xsl:result-document>
</for-each loop>
</stylesheet>
The XSL file I am using (as an example) is below. Does anyone have any
suggestions or is this simply impossible. I have thought about using
<xsl:message> and capturing the output but I want this to be fully
self contained in the XSLT if it can be.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xslaram name="outputPath" />
<xsl:variable name="dataMapping"
select="document('DataMapping.xml')" />
<xsl:key name="oceans" match="mapsection[@name='oceans']/
entry" use="@clientname" />
<xsl:template match="/">
<xsl:for-each select="main/datarecord">
<xsl:result-document href="file:///{$outputPath}-
{count(ancestor::node()|preceding::*)}.xml" >
<updateRecord>
<family><xsl:value-of select="species" /></family>
<genus><xsl:value-of select="subspecies" /></genus>
<habitat>
<xsl:variable name="clientHabitat" select="location" />
<xsl:for-each select="$dataMapping">
<xsl:value-of select="key('oceans', $clientHabitat)/
@internalname"/>
</xsl:for-each>
</habitat>
<fullname><xsl:value-of select="name" /></fullname>
</updateRecord>
</xsl:result-document>
</xsl:for-each>
</xsl:stylesheet>
Any help or advice greatly appreciated
Al