xsl-list
[Top] [All Lists]

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

2008-12-21 04:52:38
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(_at_)saxonica(_dot_)com> 
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--