[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: xsl:copy, mode and source code

Subject: RE: xsl:copy, mode and source code
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 27 Aug 2004 19:11:54 +0100
mode la source
Are you using xsl:output method="text"? If you are, you will have to
generate any XML tags you want in the output "by hand".

Michael Kay 

> -----Original Message-----
> From: Dave Jarvis [mailto:djarvis@xxxxxxxxxxxxxxxx] 
> Sent: 27 August 2004 18:06
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  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()">
>      "&lt;<xsl:value-of select="name()" />&gt;"+
>      <xsl:apply-templates /> +
>      "&lt;/<xsl:value-of select="name()" />&gt;"
>    </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/.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.