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

RE: Output XML doc with XSL doc name in comment

Subject: RE: Output XML doc with XSL doc name in comment
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Wed, 8 May 2002 13:21:12 +0100
xsl value of comment
With Saxon 7.1 you can do:

<xsl:comment>
  <xsl:value-of select="saxon:serialize(document(''))"/>
</xsl:comment>

Probably of academic interest but I thought I'd let you know!

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of
> TSchutzerWeissmann@xxxxxxxxxxxxxxxx
> Sent: 08 May 2002 11:27
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Output XML doc with XSL doc name in comment
> 
> 
> Mike Ferrando wrote:
> 
> Dear Friends,
> I am attempting to output the xsl document in a comment field when I
> generate the new xml document.
> 
> I am not getting anywhere.
> 
> Anyone have a suggestion?
> 
> Sincerely,
> Mike F.
> [...]
> <xsl:template match="/">
>   <xsl:comment>
>     <xsl:variable name="rr" select="document('')"/>
>     <xsl:value-of select="concat('xyz', $rr)"/>
>   </xsl:comment>
>   <LLL>
>    <xsl:apply-templates select="//*"/>
>   </LLL>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> --------------------------------------------------------
> Hello Mike,
> 
> xsl:value-of will give you the text nodes in your xsl - 
> that's unlikely to
> be very much. To copy of the whole lot, one would use <xsl:copy-of
> select="document('')"/>, but inside a comment this does even 
> less. So it
> looks like you can only put text inside comments.
> 
> In that case you will need something that turns xml into 
> text. You could do
> this with templates, I've included an example below.
> 
> There's no template for processing instructions, and I can't 
> work out how to
> include the namespace declarations, which is a problem, as is 
> the fact that
> the &lt; and &gt; in the stylesheet come out as < and >. 
> 
> Hope this is some use, 
> Tom Weissmann
> 
> <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
> 
> <xsl:stylesheet version='1.0'
> xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
> 
> <xsl:template match='/'>
> 	<xsl:comment>
> 		<xsl:apply-templates select ="document('')/*" mode
> ="toText"/>
> 	</xsl:comment>
> </xsl:template>
> 
> <!-- match elements -->
> 	<xsl:template match ="*" mode='toText'>
> 		<xsl:choose>
> 		<!-- elements containing stuff need an end tag, 
> empty ones
> don't -->
> 			<xsl:when test ="*|text()|comment()">
> 				<xsl:text>&lt;</xsl:text>
> 				<xsl:value-of select ="name()"/>
> 					<xsl:apply-templates
> select='namespace' mode="toText"/>
> 					<xsl:apply-templates select='@*'
> mode="toText"/>
> 				<xsl:text>&gt;</xsl:text>
> 				<xsl:apply-templates mode = "toText"/>
> 				<xsl:text>&lt;/</xsl:text>
> 					<xsl:value-of select ="name()"/>
> 				<xsl:text>&gt;</xsl:text>
> 		</xsl:when>
> 	<!-- do an empty element -->
> 		<xsl:otherwise>
> 			<xsl:text>&lt;</xsl:text>
> 			<xsl:value-of select ="name()"/>
> 			<xsl:apply-templates select='namespace'
> mode="toText"/>
> 					<xsl:apply-templates select='@*'
> mode="toText"/>
> 			<xsl:text>/&gt;</xsl:text>
> 		</xsl:otherwise>
> 		</xsl:choose>
> 	</xsl:template>
> 	
> 	<!-- match attributes -->
> 	<xsl:template match='@*' mode='toText'>
> 		<xsl:text> </xsl:text>
> 			<xsl:value-of select='name()'/>
> 		<xsl:text>="</xsl:text><xsl:value-of select ="."/>
> 		<xsl:text>" </xsl:text>
> 	</xsl:template>
> 
> 	<!-- match text -->
> 	<xsl:template match='text()' mode='toText'>
> 			<xsl:value-of select='.'/>
> 	</xsl:template>
> 
> 	<!-- match comments -->
> 	<xsl:template match ="comment()" mode ="toText">
> 		<xsl:text>&lt;--</xsl:text>
> 		<xsl:value-of select='.'/>
> 		<xsl:text>--&gt;</xsl:text>
> 	</xsl:template>
> 
> </xsl:stylesheet>
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.