|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] xsl:copy, mode and source code
Hello,
I must simplify Java/C source code into a high-level XML representation (which is transformed into source code). I've hit a snag and would really appreciate some help. Consider the following XML, within the "axe" namespace: <axe:message type="response">
<pingResult><axe:value-of select="pingOutput" /></pingResult>
</axe:message>The "axe:message" content can contain XML code or text: <axe:message type="response">
<nesting level="1">
<pingResult><axe:value-of select="pingOutput" /></pingResult>
</nesting>
</axe:message>The relevant XSL templates include: <xsl:template match="axe:message[@type='response']">
AGENT_m.append( <xsl:apply-templates mode="response" /> );
</xsl:template> <xsl:template match="@*|node()" mode="response">
X<xsl:copy><xsl:apply-templates select="@*|node()" /></xsl:copy>
</xsl:template> <xsl:template match="*" mode="response">
Y<xsl:apply-templates />
</xsl:template> <!-- Used by "axe:var", but may be applicable here ... -->
<xsl:template match="*|text()">
"<xsl:copy-of select="." />"
<xsl:if test="position() != last()">+</xsl:if>
</xsl:template>The result from debugging the template: AGENT_m.append(
X
X
Y
AGENT_pingOutput );The desired result: AGENT_m.append(
"<pingResult>" +
AGENT_pingOutput +
"</pingResult>" );I could try an ugly hack: <xsl:template match="@*|node()">
"<<xsl:value-of select="name()" />>"+
<xsl:apply-templates /> +
"</<xsl:value-of select="name()" />>"
</xsl:template>I've also tried xsl:copy-of (for a deep copy), and xsl:for-each over all elements, but no matter what I do, I just can't seem to make <pingResult> appear (much less in quotes with concatentation). I've read numerous FAQs, a few mailing lists, and searched Google. After two days of wrestling, I'm stumped; everything I've read leads me to believe that <pingResult> should appear -- but it doesn't! Is there an elegant solution? Many thanks for any ideas, or smacks along the upside of my head. Sincerely, Dave Jarvis P.S. I'm using libxslt from http://xmlsoft.org/XSLT/.
|
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








