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

AW: exlt set.distinct.template.xsl ?

Subject: AW: exlt set.distinct.template.xsl ?
From: "Braumüller, Hans" <h.braumueller@xxxxxxxxxxxx>
Date: Thu, 14 Mar 2002 16:58:58 +0100
xsl call template distinct
Hello,

thanks, i am now sure, that i understand correctly the difference between
value-of and copy-of.

But only my adaption functions well, as i expect. Enclosed i copy you the
example from exslt that i cannot run correctly:

The change that i did is to tranfer the snippet <xsl:template
match="node()|@*" mode="set:distinct">
<xsl:copy-of select="."/>   
</xsl:template>

to the transformation stylesheet  set.distinct.1.xsl, because i want to
customize the output adding an semi-colon (;) and the second adaption was
changing copy-of with value-of, to some obtain  some output.

How can i gain the same result without changing the original template from
exslt ?

Is there a tool, where i can see the result xml code?

Thanks, Hans
source:

<?xml version="1.0"?> 
<?xml:stylesheet href="set.distinct.1.xsl" type="text/xsl"?>
<doc>
<city name="Paris" country="France"/>
<city name="Madrid" country="Spain"/>
<city name="Vienna" country="Austria"/>
<city name="Barcelona" country="Spain"/>
<city name="Salzburg" country="Austria"/>
<city name="Bonn" country="Germany"/>
<city name="Lyon" country="France"/>
<city name="Hannover" country="Germany"/>
<city name="Calais" country="France"/>
<city name="Berlin" country="Germany"/>
</doc>

transform default:


<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:set="http://exslt.org/sets"
extension-element-prefixes="set">
	<xsl:import href="set.distinct.template.xsl" />
	<!-- Test exslt:distinct -->
	<xsl:template match="/">
		<b>all</b>     :
		<xsl:for-each select="//@country">
			<xsl:value-of select="." />
			;
		</xsl:for-each>
		<br />
		<b>dinstinct</b> :
		<xsl:call-template name="set:distinct">
			<xsl:with-param name="nodes" select="//@country" />
		</xsl:call-template>
	</xsl:template>
</xsl:stylesheet>


template default:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:exsl="http://exslt.org/functions"
                xmlns:set="http://exslt.org/sets"
                extension-element-prefixes="exsl"
                exclude-result-prefixes="set">

<xsl:template name="set:distinct">
   <xsl:param name="nodes" select="/.." />
 
   <xsl:choose>
      <xsl:when test="not($nodes)" />
	  
      <xsl:otherwise>
	
         <xsl:apply-templates select="$nodes[1][not(. = $nodes[position() >
1])]"
                              mode="set:distinct" />
         <xsl:call-template name="set:distinct">
            <xsl:with-param name="nodes" select="$nodes[position() > 1]" />
         </xsl:call-template>
      </xsl:otherwise>
   </xsl:choose>
</xsl:template>


<xsl:template match="node()|@*" mode="set:distinct">
<xsl:copy-of select="."/>   
</xsl:template>

</xsl:stylesheet>


transform adaption:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:set="http://exslt.org/sets"
extension-element-prefixes="set">
	<xsl:import href="set.distinct.template.xsl" />
	<!-- Test exslt:distinct -->
	<xsl:template match="/">
		<b>all</b>     :
		<xsl:for-each select="//@country">
			<xsl:value-of select="." />
			;
		</xsl:for-each>
		<br />
		<b>dinstinct</b> :
		<xsl:call-template name="set:distinct">
			<xsl:with-param name="nodes" select="//@country" />
		</xsl:call-template>
	</xsl:template>
	
<xsl:template match="node()|@*" mode="set:distinct">
<xsl:value-of select="."/>;   
</xsl:template>

</xsl:stylesheet>

template adaption:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:exsl="http://exslt.org/functions"
                xmlns:set="http://exslt.org/sets"
                extension-element-prefixes="exsl"
                exclude-result-prefixes="set">

<xsl:template name="set:distinct">
   <xsl:param name="nodes" select="/.." />
 
   <xsl:choose>
      <xsl:when test="not($nodes)" />
	  
      <xsl:otherwise>
	
         <xsl:apply-templates select="$nodes[1][not(. = $nodes[position() >
1])]"
                              mode="set:distinct" />
         <xsl:call-template name="set:distinct">
            <xsl:with-param name="nodes" select="$nodes[position() > 1]" />
         </xsl:call-template>
      </xsl:otherwise>
   </xsl:choose>
</xsl:template>



</xsl:stylesheet>




> -----Ursprüngliche Nachricht-----
> Von: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]Im Auftrag von cutlass
> Gesendet: Donnerstag, 14. März 2002 15:37
> An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Betreff: Re:  exlt set.distinct.template.xsl ?
> 
> 
> Hello Hans,
> 
> > Can anyone please explain , the difference between   <xsl:value-of
> > select="."/> and <xsl:copy-of select="." /> ?
> 
> without seeing your whole code in context and result i cant 
> comment in any
> great detail as the template is tested and works properly.
> 
> the difference between value of returns the value contained 
> within the xml
> tags, copy or copy-of returns the xml result.
> 
> i assume that u actually recieved the correct result, but did 
> not *see*
> it...as it was wrapped in xml, and u probably outputted html
> 
> the following example xml and xsl clearly illustrates the 
> difference between
> value-of and copy-of
> 
> 
> xsl
> ----------------------------------
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>  <xsl:template match="root">
> 
>  this is copy of
>  <xsl:apply-templates select="test" mode="test1"/>
> 
>  <br/>
> 
>  this is value of
>  <xsl:apply-templates select="test" mode="test2"/>
>  </xsl:template>
> 
>  <xsl:template match="test" mode="test1">
>  <xsl:copy-of select="."/>
>  </xsl:template>
> 
>  <xsl:template match="test" mode="test2">
>  <xsl:value-of select="."/>
>  </xsl:template>
> 
> </xsl:stylesheet>
> 
> xml
> ------------------------------------------
> <?xml version="1.0" ?>
> <root>
> 
> <test>1</test>
> 
> <test>2</test>
> 
> 
> </root>
> 
> 
> 
> HTH, jim fuller
> >
> > Thanks,
> >
> >
> > Hans Braumüller
> > -- + --
> > Networking Artist
> > http://crosses.net
> > http://kunstserie.com
> >
> >
> >
> >  XSL-List info and archive:  
http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.