[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Use of separator

Subject: Re: Use of separator
From: "Georg Hohmann" <georg.hohmann@xxxxxxxxx>
Date: Tue, 8 Aug 2006 09:34:18 +0200
text separator
Hello,
please excuse me for not giving a complete example of the source file.
Here is my second attempt ... I made a little testbed which consists
of one source file and two xslt stylesheets. Here is the source:

<?xml version="1.0" encoding="UTF-8"?>
<root>
	<wrapper>
		<node1>Text1</node1>
		<node2>Text2</node2>
		<node3>Text3</node3>
	</wrapper>
	<wrapper>
		<node1>Text1</node1>
		<node2>Text2</node2>
		<node3>Text3</node3>
	</wrapper>
	<wrapper>
		<node1>Text1</node1>
		<node2>Text2</node2>
		<node3>Text3</node3>
	</wrapper>
</root>

Stylesheet 1:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="wrapper">
		<helloWorld>
			<xsl:value-of select="element()/text()" separator=", "/>
		</helloWorld>
	</xsl:template>
</xsl:stylesheet>

Output of Stylesheet 1:
<?xml version="1.0" encoding="UTF-8"?>
<helloWorld>Text1Text2Text3</helloWorld>
<helloWorld>Text1Text2Text3</helloWorld>
<helloWorld>Text1Text2Text3</helloWorld>

Stylesheet 2:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="wrapper">
		<helloWorld>
			<xsl:value-of select="*" separator=", "/>
		</helloWorld>
	</xsl:template>
</xsl:stylesheet>

Output of Stylesheet 2:
<?xml version="1.0" encoding="UTF-8"?>
<helloWorld>Text1, Text2, Text3</helloWorld>
<helloWorld>Text1, Text2, Text3</helloWorld>
<helloWorld>Text1, Text2, Text3</helloWorld>

Although the output files are no valid xml due to the lack of a root
element they show the different use of the separator.

Regards,
Georg



2006/8/7, David Carlisle <davidc@xxxxxxxxx>:

you didn't show your input so i'll have to guess,


if the doc is

<x>
 <a>one<!-- here -->two</a>
 <a>three</a>
 <a>four</a>
</x>

and the current node is x then

element()/text() will select four text nodes with values "one" "two"
      "three" "four"
so
      <xsl:value-of select="element()/text()" separator=", "/>
will generate one text node with value
"one, two, three, four"


* will select three element nodes, each with name a and with string values "onetwo" "three" "four" so

<xsl:value-of select="*" separator=", "/>
will generate one text node with string value
"onetwo", "three", "four"


> Now i wonder why the result of the first expression contains no > separator while the other one does. Any explanations? presumably it selected a sequence of length 1, but without seeing the input it's hard to say.

David

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.