Subject: Re: [xsl] transforming xml data in cdata From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sun, 08 Nov 2009 22:24:46 -0500 |
Hi, I have the following xml data:
<Sale><Site>101</Site>
<Details><![CDATA[ <?xml version="1.0"?><items><item>desk</item><cost>10</cost></items> ]]>
</Details>
</Sale>
I have an xslt "my.xslt" that tranforms the elements above except cdata part to result.xml. e.g <SalesItem><Location>101</Location></SalesItem>
However, I also have "another.xslt" that can transform the xml part within the cdata section.
I would like to import "another.xslt" into my.xslt and be able to transform the xml document within cdata as well.
With the result looking similar to the following:
<SalesItem><Location>101</Location><SkuDetails>
<![CDATA<?xml version="1.0"?><skus><sku>desk</sku><amount>10</amount></skus>]]>
</SkuDetails></SalesItem>
Any ideas would be appreciated if this can be accomplished.
T:\ftemp>type temp.xml <?xml version="1.0"?><items><item>desk</item><cost>10</cost></items>
<xsl:template match="/"> <xsl:value-of select="Sale/Details"/> </xsl:template>
</xsl:stylesheet> T:\ftemp>type speeder2.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="items"> <skus> <xsl:apply-templates/> </skus> </xsl:template>
<xsl:template match="item"> <sku> <xsl:apply-templates/> </sku> </xsl:template>
<xsl:template match="cost"> <amount> <xsl:apply-templates/> </amount> </xsl:template>
T:\ftemp>type speeder3.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="Sale"> <SalesItem> <xsl:apply-templates/> </SalesItem> </xsl:template>
<xsl:template match="Site"> <Location> <xsl:apply-templates/> </Location> </xsl:template>
<xsl:template match="Details"> <SkuDetails> <xsl:value-of select="unparsed-text($detailsfile)"/> </SkuDetails> </xsl:template>
-- Upcoming: hands-on XSLT, XQuery and XSL-FO Washington DC Nov 2009 Interested in other classes? http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] transforming xml data in cdat, road speeder | Thread | Re: [xsl] transforming xml data in , Wolfgang Laun |
[xsl] transforming xml data in cdat, road speeder | Date | Re: [xsl] transforming xml data in , Wolfgang Laun |
Month |