Subject: [xsl] Attribute "separator" of xsl:value-of in XSLT 2.0 From: Christian Rinderknecht <konchog.zangpo@xxxxxxxxx> Date: Mon, 09 May 2011 19:48:14 +0900 |
I have a beginner's question about the behaviour of the attribute "separator" of the element xsl:value-of in XSLT 2.0.
"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."
"[...] <xsl:value-of select="author"/> [...] all the authors are now output, using a single space as the default separator."
<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
PS In case this is not a totally stupid question, here is my complete example.
<!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>
<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>
<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>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Negative lookahead/behind, Wolfgang Laun | Thread | Re: [xsl] Attribute "separator" of , Brandon Ibach |
Re: [xsl] Negative lookahead/behind, Andrew Welch | Date | Re: [xsl] Attribute "separator" of , Brandon Ibach |
Month |