Subject: Re: [xsl] Attribute "separator" of xsl:value-of in XSLT 2.0 From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx> Date: Mon, 09 May 2011 13:04:16 +0200 |
<xsl:template match="author"> <xsl:if test="first"> <xsl:value-of select="first" /> <xsl:text> </xsl:text> </xsl:if> <xsl:value-of select="last" /> </xsl:template>
Dear list members,
I have a beginner's question about the behaviour of the attribute "separator" of the element xsl:value-of in XSLT 2.0.
The standard at section 11.4.3 states:
"If the separator attribute is present, then the effective value of this attribute is used to separate adjacent items in the result sequence, as described in 5.7.2 Constructing Simple Content. In the absence of this attribute, the default separator is a single space (#x20) when the content is specified using the select attribute, or a zero-length string when the content is specified using a sequence constructor."
The Big Book by Michael Kay (4th ed.), page 498--499 says:
"[...] <xsl:value-of select="author"/> [...] all the authors are now output, using a single space as the default separator."
Let us say that I have a subtree like
<author> <first>Priscilla</first> <last>Walmsley</last> </author>
Using Saxon HE 9-3-0-4j and assuming the current node is the parent of author, the result of
<xsl:value-of select="author" separator=" "/>
or
<xsl:value-of select="author" separator="' '"/>
is the same as
<xsl:value-of select="author"/>
that is, 'PriscillaWalmsley'. But
<xsl:value-of select="author/first,author/last"/>
produces
'Priscilla Walmsley'.
Is this the semantics intended?
Best regards,
Christian
PS In case this is not a totally stupid question, here is my complete example.
book.dtd is
<!ELEMENT book (author, chapter+)> <!ATTLIST book title CDATA #REQUIRED>
<!ELEMENT author (first,last)> <!ELEMENT first (#PCDATA)> <!ELEMENT last (#PCDATA)>
<!ELEMENT chapter (section*)> <!ATTLIST chapter title CDATA #REQUIRED>
<!ELEMENT section (section*)> <!ATTLIST section title CDATA #REQUIRED>
num1.xml is
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE book SYSTEM "book.dtd">
<book title="Definitive XML Schema"> <author> <first>Priscilla</first> <last>Walmsley</last> </author>
<chapter title="A quick tour of XML Schema"> <section title="An example schema"/> <section title="The components of XML Schema"> <section title="Declarations vs. definitions"/> <section title="Global vs. local components"/> </section> <section title="Elements and attributes"> <section title="The tag/type distinction"/> </section> </chapter>
<chapter title="Instances and schemas"> <section title="Using the instance attributes"/> <section title="Schema processing"> <section title="Validation"/> <section title="Augmenting the instance"/> </section> </chapter>
<chapter title="Conclusion"/>
</book>
num1.xsl is
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xsl:output method="xhtml" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/"> <xsl:apply-templates select="book"/> <xsl:text> </xsl:text> </xsl:template>
<xsl:template match="book" as="element(xhtml:html)"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title><xsl:value-of select="@title"/></title> </head> <body> <h2><xsl:value-of select="@title"/></h2> <p>by <xsl:value-of select="author"/></p> <h3>Table of contents</h3> <ul> <xsl:apply-templates select="chapter"/> </ul> </body> </html> </xsl:template>
<xsl:template match="section|chapter" as="element(xhtml:li)"> <li xmlns="http://www.w3.org/1999/xhtml"> <xsl:value-of select="@title"/> <xsl:if test="not(empty(section))"> <ul> <xsl:apply-templates select="section"/> </ul> </xsl:if> </li> </xsl:template>
</xsl:transform>
-- Gerrit Imsieke GeschC$ftsfC<hrer / Managing Director le-tex publishing services GmbH Weissenfelser Str. 84, 04229 Leipzig, Germany Phone +49 341 355356 110, Fax +49 341 355356 510 gerrit.imsieke@xxxxxxxxx, http://www.le-tex.de
Registergericht / Commercial Register: Amtsgericht Leipzig Registernummer / Registration Number: HRB 24930
GeschC$ftsfC<hrer: Gerrit Imsieke, Svea Jelonek, Thomas Schmidt, Dr. Reinhard VC6ckler
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Attribute "separator" of , Brandon Ibach | Thread | Re: [xsl] Attribute "separator" of , Martin Honnen |
Re: [xsl] Attribute "separator" of , Brandon Ibach | Date | Re: [xsl] Attribute "separator" of , Martin Honnen |
Month |