This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
AW: exlt set.distinct.template.xsl ?
- From: "Braumüller, Hans" <h dot braumueller at hanseorga dot de>
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Date: Thu, 14 Mar 2002 16:58:58 +0100
- Subject: AW: [xsl] exlt set.distinct.template.xsl ?
- Reply-to: xsl-list at lists dot mulberrytech dot com
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@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]Im Auftrag von cutlass
> Gesendet: Donnerstag, 14. März 2002 15:37
> An: xsl-list@lists.mulberrytech.com
> Betreff: Re: [xsl] 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