[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Inserting commented elements into output file


Subject: [xsl] Inserting commented elements into output file
From: "Steve Schwarz" <saschwarz@xxxxxxxxxxx>
Date: Thu, 12 Jun 2003 03:02:25 +0000

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




Current Thread
Keywords
xml