|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] How to incrementally add to a result document?
Hi Folks,
I have an XSLT program that converts an old form to a new form. My XSLT
program has a template rule that converts this old form:
<Airport_Name>Boston Logan Airport</Airport_Name>
to this new form:
<name>Boston Logan Airport</name>
My XSLT program has a template rule that converts this old form:
<Airport_Elevation>19</Airport_Elevation>
to this new form:
<elevation>19</elevation>
I want the template rules to also output -- to another, different file --
metadata that shows what actions were taken. Here is the template rule for
Airport_Name:
-----------------------------------------------------------
<xsl:template match="Airport_Name">
<name>
<xsl:value-of select="normalize-space(.)"/>
</name>
<!-- output metadata showing the actions taken -->
<xsl:result-document href="metadata.xml" format="XML-format">
<mapping>
<legacy-elmt-name>
<xsl:value-of select="name()"/>
</legacy-elmt-name>
<legacy-elmt-value>
<xsl:value-of select="."/>
</legacy-elmt-value>
<new-elmt-name>
<xsl:text>name</xsl:text>
</new-elmt-name>
<new-elmt-value>
<xsl:value-of select="normalize-space(.)"/>
</new-elmt-value>
</mapping>
</xsl:result-document>
</xsl:template>
-----------------------------------------------------------
Here is the template rule for Airport_Elevation:
-----------------------------------------------------------
<xsl:template match="Airport_Elevation">
<elevation>
<xsl:if test=". castable as xs:integer">
<xsl:value-of select="xs:integer(.)"/>
</xsl:if>
</elevation>
<!-- output metadata showing the actions taken -->
<xsl:result-document href="metadata.xml" format="XML-format">
<mapping>
<legacy-elmt-name>
<xsl:value-of select="name()"/>
</legacy-elmt-name>
<legacy-elmt-value>
<xsl:value-of select="."/>
</legacy-elmt-value>
<new-elmt-name>
<xsl:text>elevation</xsl:text>
</new-elmt-name>
<new-elmt-value>
<xsl:if test=". castable as xs:integer">
<xsl:value-of select="xs:integer(.)"/>
</xsl:if>
</new-elmt-value>
</mapping>
</xsl:result-document>
</xsl:template>
-----------------------------------------------------------
Here is how the template rules are activated:
<airport>
<xsl:apply-templates select="Airport_Name"/>
<xsl:apply-templates select="Airport_Elevation"/>
</airport>
When I run my XSLT program I get this error message:
Error in xsl:result-document/@href
XTDE1490 Cannot write more than one result document to the same URI
The error message is telling me that I cannot write to the metadata.xml file
in an incremental fashion, right?
What to do?
Is there anyway that I can achieve what I desire -- output to one document the
result of mapping the old form to the new form and output to another document
metadata that describes the mapping steps that were taken? Or is this outside
the realm of XSLT's capabilities?
/Roger
|
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








