Subject: RE: [xsl] Result tree fragment to string? From: "Houghton,Andrew" <houghtoa@xxxxxxxx> Date: Wed, 27 Aug 2008 13:47:51 -0400 |
> From: David Carlisle [mailto:davidc@xxxxxxxxx] > Sent: Wednesday, August 27, 2008 12:20 PM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: [xsl] Result tree fragment to string? > > > > Do I have any options left for converting the result tree fragment to > a > > string? > > no Hmm... could he do something like: <xsl:variable name="xml"> <xsl:call-template name="serialize-tree"> <xsl:with-param name="nodes" select="$result-tree" /> </xsl:call-template> </xsl:variable> <xsl:template name="serialize-tree"> <xsl:param name="nodes" /> <xsl:apply-templates select="$nodes" mode="serialize" /> </xsl:template> <xsl:template name="quote-attribute"> <xsl:param name="value" /> <!-- quote attribute's value --> </xsl:template> <xsl:template match="node()" mode="serialize" /> <xsl:template match="@*" mode="serialize"> <xsl:variable name="dq"> <xsl:text>"</xsl:text> </xsl:variable> <xsl:variable name="value"> <xsl:call-template name="quote-attribute"> <xsl:with-param name="value" select="." /> </xsl:call-template> </xsl:variable> <xsl:value-of select="concat(' ',local-name(),'=',$dq,$value,$dq)" /> </xsl:template> <xsl:template match="*" mode="serialize"> <xsl:value-of select="concat('<',local-name())" /> <xsl:apply-templates select="@*" mode="serialize" /> <xsl:value-of select="string('>')" /> <xsl:apply-templates select="*" mode="serialize" /> <xsl:value-of select="concat('</',local-name(),'>')" /> </xsl:template> The above doesn't handle namespaces, processing-instructions, comments, or mixed content, but it could be hacked to do so. Is there a reason why this approach would not work in XSL 1.0 to satisfy his needs? Andy.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Result tree fragment to s, Wendell Piez | Thread | Re: [xsl] Result tree fragment to s, Martin Honnen |
[xsl] Schema awareness with XSLT 1., Mukul Gandhi | Date | RE: [xsl] Result tree fragment to s, Garriss Jr., James P |
Month |