xsl-list
[Top] [All Lists]

RE: Inserting commented elements into output file

2003-06-12 04:21:29
There is no such thing in the data model as "a commented element" -
comment nodes can contain only text, they cannot contain other nodes as
children. The things that look like start and end tags in your example
are not tags at all, they are ordinary characters.

You could try using saxon:serialize() to simulate this effect.

Michael Kay

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
Steve Schwarz
Sent: 12 June 2003 04:02
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Inserting commented elements into output file


Hi
I've been scratching my head on this and can't figure out a 
solution. I have 
some XML documents that I'm converting to HTML and I am 
putting the same 
boilerplate RDF content into every file. I can get the RDF 
content into the 
html file but I can't figure out how to wrap the RDF content 
with a comment 
to make it acceptable by old browsers.

A boiled down version of my stylesheet:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="1.0">
  <xsl:output method="html" indent="yes"/>
  <xsl:strip-space elements="*"/>

<xsl:template match="/">
<html><head>
<title>test</title>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
<Work rdf:about="">
<license 
rdf:resource="http://creativecommons.org/licenses/by-nc-sa/1.0
/" /> </Work> <License 
rdf:about="http://creativecommons.org/licenses/by-nc-sa/1.0/";>
   <requires rdf:resource="http://web.resource.org/cc/Attribution"; />
   <requires rdf:resource="http://web.resource.org/cc/ShareAlike"; />
   <permits rdf:resource="http://web.resource.org/cc/Reproduction"; />
   <permits rdf:resource="http://web.resource.org/cc/Distribution"; />
   <permits 
rdf:resource="http://web.resource.org/cc/DerivativeWorks"; />
   <prohibits 
rdf:resource="http://web.resource.org/cc/CommercialUse"; />
   <requires rdf:resource="http://web.resource.org/cc/Notice"; 
/> </License> </rdf:RDF> </head> <body></body> </html> 
</xsl:template> </xsl:stylesheet>

which produces:
<html>
<head>
<META http-equiv="Content-Type" content="text/html; 
charset=UTF-8"> <title>test</title> <rdf:RDF 
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
<Work rdf:about="">
<license 
rdf:resource="http://creativecommons.org/licenses/by-nc-sa/1.0
/"></license>
</Work>
<License 
rdf:about="http://creativecommons.org/licenses/by-nc-sa/1.0/";>
<requires 
rdf:resource="http://web.resource.org/cc/Attribution";></requires>
<requires 
rdf:resource="http://web.resource.org/cc/ShareAlike";></requires>
<permits 
rdf:resource="http://web.resource.org/cc/Reproduction";></permits>
<permits 
rdf:resource="http://web.resource.org/cc/Distribution";></permits>
<permits 
rdf:resource="http://web.resource.org/cc/DerivativeWorks";></permits>
<prohibits 
rdf:resource="http://web.resource.org/cc/CommercialUse";></prohibits>
<requires rdf:resource="http://web.resource.org/cc/Notice";></requires>
</License>
</rdf:RDF>
</head>
<body></body>
</html>

But I'd like to produce the following (where the rdf:RDF element is 
surrounded by comments):
<html>
<head>
<META http-equiv="Content-Type" content="text/html; 
charset=UTF-8"> <title>test</title>
<!--
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
<Work rdf:about="">
<license 
rdf:resource="http://creativecommons.org/licenses/by-nc-sa/1.0
/"></license>
</Work>
<License 
rdf:about="http://creativecommons.org/licenses/by-nc-sa/1.0/";>
<requires 
rdf:resource="http://web.resource.org/cc/Attribution";></requires>
<requires 
rdf:resource="http://web.resource.org/cc/ShareAlike";></requires>
<permits 
rdf:resource="http://web.resource.org/cc/Reproduction";></permits>
<permits 
rdf:resource="http://web.resource.org/cc/Distribution";></permits>
<permits 
rdf:resource="http://web.resource.org/cc/DerivativeWorks";></permits>
<prohibits 
rdf:resource="http://web.resource.org/cc/CommercialUse";></prohibits>
<requires rdf:resource="http://web.resource.org/cc/Notice";></requires>
</License>
</rdf:RDF>
-->
</head>
<body></body>
</html>

I've tried wrapping the <rdf> element with <xsl:comment> but 
Xalan doesn't 
like that; I've tried building the comments from <xsl:text> and 
<xsl:value-of select... with concat> but I can't find a 
syntax that is 
acceptable. I sure this must be trivial and I'm just not getting it.

Thank you for any assistance,
Steve Schwarz

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail


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



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



<Prev in Thread] Current Thread [Next in Thread>