Re: [xsl] Newbie question, commenting out an element

Subject: Re: [xsl] Newbie question, commenting out an element
From: George Cristian Bina <george@xxxxxxxxxxxxx>
Date: Sun, 21 Dec 2008 21:36:25 +0200
You need to declare the serialize extension namespace using saxon as prefix. Add

xmlns:saxon="http://saxon.sf.net/";

on your xsl:stylesheet element for example.

Best Regards,
George
--
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


Douglas Wade wrote:
thanks for this great help. I could not get this to work,

<xsl:output name="ser-x" method="xml" omit-xml-declaration="yes" indent="yes" />

<xsl:comment>
 <xsl:value-of select="saxon:serialize(applic, 'ser-x')" />
</xsl:comment>

I am using Oxygen 10 and tried Saxon-B 9.1.0.3 and even Saxon-SA
9.1.0.3. The error is on char 32 the contents of the select. I am not
sure why. But, I think I am following along. Could it be that I do not
have saxon extensions or some NS?

d


On Sun, Dec 21, 2008 at 1:52 AM, Mukul Gandhi <gandhi.mukul@xxxxxxxxx> wrote:
The following works fine with Saxon 9.

<xsl:output name="ser-x" method="xml" omit-xml-declaration="yes" indent="yes" />

<xsl:comment>
 <xsl:value-of select="saxon:serialize(applic, 'ser-x')" />
</xsl:comment>

I have few questions,

1. Can we have serialize functionality in a future XSLT version
(perhaps 2.1), something like, xsl:serialize(...) which exactly
follows the Saxon serialize extension semantics?
saxon:serialize seems to me a quite useful extension, and I think it
could be available in standard XSLT.

2. XSLT 2.0 allows us to define xsl:output elements with 'name'
attribute, which can be used in saxon:serialize function (as shown
above). Apart from saxon:serialize function, do any standard XSLT 2.0
instructions/facilities use xsl:output elements having 'name'
attribute?

On Sun, Dec 21, 2008 at 3:02 PM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
I am new to the list and to XSLT. I want to transform a XML
file to another XML file. In the process I have a Applic tag
that I want to wrap in a comment.
Comments can't contain tags. If you look at XML more carefully, you will see
that any "<" and ">" characters are not treated as markup (or tags), they
are ordinary data characters. They might look like tags, but the appearance
is deceptive.

This is reflected in the XSLT/XPath data model: a comment node cannot have
element nodes as its children.

So to solve this, you need to serialize the elements as strings, and then
put the strings in the comment node. You can do the serialization by hand
(but be careful with special characters like "&"), or use something like
saxon:serialize().

Michael Kay
http://www.saxonica.com/


--
Regards,
Mukul Gandhi

Current Thread