<?xml version="1.0" encoding="UTF-8"?>

<rdf:RDF
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns="http://purl.org/rss/1.0/"
 xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:syn="http://purl.org/rss/1.0/modules/syndication/"
 xmlns:admin="http://webns.net/mvcb/"
>

<channel rdf:about="http://ASPN.ActiveState.com/ASPN/Mail/Browse/Threaded/XSL-List">
<title>XSL-List archive @ ASPN</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Browse/Threaded/XSL-List</link>
<description>Open forum for the discussion of XSL -- Extensible Stylesheet Language. </description>
<dc:language>en-us</dc:language>
<dc:rights>Copyright 2005, ActiveState</dc:rights>
<dc:publisher>aspn-feedback@activestate.com</dc:publisher>
<dc:creator>aspn-feedback@activestate.com</dc:creator>
<dc:subject>ASPN Mail Archive</dc:subject>
<syn:updatePeriod>hourly</syn:updatePeriod>
<syn:updateFrequency>1</syn:updateFrequency>
<syn:updateBase>1901-01-01T00:00+00:00</syn:updateBase>
<items>
 <rdf:Seq>
  <rdf:li rdf:resource="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173732" />
  <rdf:li rdf:resource="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173731" />
  <rdf:li rdf:resource="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173659" />
  <rdf:li rdf:resource="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173631" />
  <rdf:li rdf:resource="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173630" />
  <rdf:li rdf:resource="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173629" />
  <rdf:li rdf:resource="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173498" />
  <rdf:li rdf:resource="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173497" />
  <rdf:li rdf:resource="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173496" />
  <rdf:li rdf:resource="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173495" />
 </rdf:Seq>
</items>
<image rdf:resource="http://ASPN.ActiveState.com/ASPN/img/logo_78x25.gif" />
</channel>

<image rdf:about="http://ASPN.ActiveState.com/ASPN/img/logo_78x25.gif">
<title>XSL-List @ ASPN Mail Archive</title>
<url>http://ASPN.ActiveState.com/ASPN/img/logo_78x25.gif</url>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Browse/Threaded/XSL-List</link>
<dc:creator>G. Raphics (graphics @ ActiveState)</dc:creator>
</image>

<item rdf:about="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173732">
<title>[xsl] RE : [xsl] document() vs. current()</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173732</link>
<description>&lt;PRE>Marco Plum wrote:

  Hi

> So I thought that perhaps the function document() changes the context
> and I have to use the function current(), but I did not get the
> result I expected...

  Yes, it does.  What did you try?  Could you please try:

    current()/dd/...

  Regards,

--drkm


































	

	
		
___________________________________________________________________________ 
Yahoo! Mail rÃ©invente le mail ! DÃ©couvrez le nouveau Yahoo! Mail et son interface
rÃ©volutionnaire.
http://fr.mail.yahoo.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: &lt;mailto:xsl-list-unsubscribe@...
--~--
&lt;/PRE></description>
<dc:creator>Florent Georges (darkman_spam@...)</dc:creator>
<dc:subject>XSL-List</dc:subject>
</item>

<item rdf:about="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173731">
<title>Re: [xsl] document() vs. current()</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173731</link>
<description>&lt;PRE>current()/dd/vd[@... ='x']/@...
should work (tested with saxon 8.6)

HTH,
Anton

Marco Plum wrote:

>If I change
>
>/dd/vd[@... ='x']/@...
>
>into its actual value (1), everything works fine...
>
>So I thought that perhaps the function document() changes the context and I have to use
the function current(), but I did not get the result I expected...
>
>  
>


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: &lt;mailto:xsl-list-unsubscribe@...
--~--
&lt;/PRE></description>
<dc:creator>Anton Triest (anton@...)</dc:creator>
<dc:subject>XSL-List</dc:subject>
</item>

<item rdf:about="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173659">
<title>[xsl] document() vs. current()</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173659</link>
<description>&lt;PRE>I hope that this
hasn't been asked here before - at least I did not find a solution searching through the
list archive:

My XSL contains a lookup table im accessing via document(''). In order to know, which value
I need to look up, I have to get another value from my input XML. Im trying something like
that:

INPUT:

&lt;dd>
	&lt;vd name="aName" val="aValue"/>
	&lt;vd name="anotherName" val="anotherValue"/>
	&lt;vd name="x" val="1"/>
&lt;/dd>


XSL:

&lt;xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="My Date Namespace">
	&lt;xsl:template match="/">
		&lt;xsl:value-of select="document('')//date:months/date:month[@... =
/dd/vd[@... ='x']/@...
	&lt;/xsl:template>
	&lt;date:months>
		&lt;date:month nr="1" name="Januar"/>
		&lt;date:month nr="2" name="Februar"/>
		&lt;date:month nr="3" name="MÃ¤rz"/>
		&lt;!-- and so on -->
	&lt;/date:months>
&lt;/xsl:stylesheet>


If I change

/dd/vd[@... ='x']/@...

into its actual value (1), everything works fine...

So I thought that perhaps the function document() changes the context and I have to use the
function current(), but I did not get the result I expected...

What am I doing wrong?

Best regards,
Marco Plum

*****************************************
Marco Plum
s&lt;e>mantics Kommunikationsmanagement GmbH
TheaterstraÃ?e 106 D - 52062 Aachen
Tel: +49 241 89498944
Fax: +49 241 89498930
eMail: m.plum@...
Web: www.semantics.de
 

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: &lt;mailto:xsl-list-unsubscribe@...
--~--
&lt;/PRE></description>
<dc:creator>Marco Plum (m.plum@...)</dc:creator>
<dc:subject>XSL-List</dc:subject>
</item>

<item rdf:about="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173631">
<title>Re: [xsl] Finding the first among equals using XPath</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173631</link>
<description>&lt;PRE>Peter,

This is a de-duplicating problem.

As in the Muenchian technique for grouping, de-duplication can be 
achieved using keys.

For example, if you have a key declaration:

&lt;xsl:key name="WXY" match="X" use="concat(generate-id(ancestor::W),'#',@...

Then, given any W as context node,

&lt;xsl:for-each select=".//X
   [generate-id() =
    generate-id(key('WXY',concat(generate-id(ancestor::W),'#',@...

will iterate only over the first X elements that appear inside the W 
with a given  @... value.

This logic can be uncompressed if you need it to be clearer. (But 
note: untested, and David has already one-upped me once today. :-)

The solution is elusive because the problem usually appears in a 
different form.

Cheers,
Wendell

At 11:45 AM 6/22/2006, you wrote:
>I am sure this is a hoary old one, but I could not work out the right
>runes to achieve it, nor the right keywords to search for to find an
>answer
>
>If I have XML like the following:
>
>&lt;V>
>  &lt;W>
>   &lt;Z/>
>	&lt;X Y='0'/>
>    &lt;X Y='0'/>
>     &lt;X Y='1'/>
>   &lt;Z/>
>   &lt;/W>
>  &lt;W>
>   &lt;Z/>
>      &lt;Z/>
>	&lt;X Y='0'/>
>     &lt;X Y='1'/>
>      &lt;X Y='2'/>
>      &lt;/W>
>   &lt;W>
>     &lt;X Y='2'/>
>      &lt;X Y='2'/>
>	&lt;X Y='2'/>
>   &lt;Z/>
>      &lt;Z/>
>	   &lt;/W>
>&lt;/V>
>
>I a have a for-each loop over the W elements. Inside the for-each I
>want to select one X with each value of Y that exists within that W.
>
>So for the above example, for //W[1] I want to get the first and third
>or second and third X elements, for //W[2] I want all three X elements
>and for //W[3] I want any one of the X elements, but only one of them.
>
>I hope that bit is clear.
>
>I have run out of ideas now, so I have finally admitted defeat (a hard
>thing for an engineer) and am asking for your collective wisdom.
>
>I want a node-set so I can do a for-each on that, so I would prefer to
>find a select specifier based on clever use of axes and predicates.


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: &lt;mailto:xsl-list-unsubscribe@...
--~--
&lt;/PRE></description>
<dc:creator>Wendell Piez (wapiez@...)</dc:creator>
<dc:subject>XSL-List</dc:subject>
</item>

<item rdf:about="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173630">
<title>Re: [xsl] Merging attributes in one XML file with node values  in another (identical structure)</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173630</link>
<description>&lt;PRE>At 11:51 AM
6/22/2006, David wrote:
> > awesomely elegant solution works
>
>'course elegance, like beauty, is in the eye of the beholder. Walking
>over the tree(s) recursively carrying a bit of state with you might take
>some more lines of code, but is probably more efficient than working out
>/descendant::*[$n] each time.

Indeed, but code footprint does make a difference, and as soon as you 
start passing parameters around, XSLT's syntax proves a significant 
impediment to its appearing graceful -- its steps may be right, but 
not light. Whether something can *be* graceful without *appearing* so 
is something I leave for us to ponder ... though I acknowledge that 
an algorithm may be nice even if its synactic expression is not.

Sort of like dancing in hiking boots. If everyone is doing it, we may 
fail to notice. But that doesn't make it pretty.

Cheers,
Wendell


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: &lt;mailto:xsl-list-unsubscribe@...
--~--
&lt;/PRE></description>
<dc:creator>Wendell Piez (wapiez@...)</dc:creator>
<dc:subject>XSL-List</dc:subject>
</item>

<item rdf:about="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173629">
<title>Re: [xsl] Finding the first among equals using XPath</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173629</link>
<description>&lt;PRE>At 11:58 AM
6/22/2006, David wrote:
>xslt2's for-each-group makes it easier (or at least easier to read) but
>any xslt 1 grouping construct would work here. Muenchian grouping (ie
>using keys) is the usual approach, but making the keys unique in
>subtrees rooted at each W is a bit tiresome, so unless you have 100's of
>X below each W I'd just write it directly in XPath
>
>something like
>
>&lt;xsl:for-each select="W">
>   &lt;xsl:for-each select="X[not(@...
>     something

I'd prefer this approach if you know all the X elements will be siblings.

Cheers,
Wendell


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: &lt;mailto:xsl-list-unsubscribe@...
--~--
&lt;/PRE></description>
<dc:creator>Wendell Piez (wapiez@...)</dc:creator>
<dc:subject>XSL-List</dc:subject>
</item>

<item rdf:about="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173498">
<title>Re: [xsl] Finding the first among equals using XPath</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173498</link>
<description>&lt;PRE>At 2006-06-22
16:45 +0100, Peter Riocreux wrote:
>I am sure this is a hoary old one, but I could not work out the right
>runes to achieve it, nor the right keywords to search for to find an
>answer

Well said.

>I a have a for-each loop over the W elements. Inside the for-each I
>want to select one X with each value of Y that exists within that W.

(data copied below)

>So for the above example, for //W[1] I want to get the first and third
>or second and third X elements, for //W[2] I want all three X elements
>and for //W[3] I want any one of the X elements, but only one of them.
>
>I hope that bit is clear.
>..
>I want a node-set so I can do a for-each on that, so I would prefer to
>find a select specifier based on clever use of axes and predicates.

Two answers are below ... both over a node set 
... but the first is the variable-based method 
which allows one to do grouping directly over 
subtrees, but requires an &lt;xsl:if> in the 
loop.  The second is using the Muenchian method 
and gives a pure node set but the subtree 
distinction achieved through the use of the 
parent's generated identifier may make those 
responsible for maintaining it difficult to understand what is going on.

>I am stuck with using XSL 1.0

That isn't a stigma to bear.  I'm still being asked to teach XSLT 1.0.

I hope the two approaches below are helpful.

. . . . . . . . . Ken

t:\ftemp>type peter.xml
&lt;V>
  &lt;W>
   &lt;Z/>
       &lt;X Y='0'/>
    &lt;X Y='0'/>
     &lt;X Y='1'/>
   &lt;Z/>
   &lt;/W>
  &lt;W>
   &lt;Z/>
      &lt;Z/>
       &lt;X Y='0'/>
     &lt;X Y='1'/>
      &lt;X Y='2'/>
      &lt;/W>
   &lt;W>
     &lt;X Y='2'/>
      &lt;X Y='2'/>
       &lt;X Y='2'/>
   &lt;Z/>
      &lt;Z/>
	  &lt;/W>
&lt;/V>

t:\ftemp>type peter.xsl
&lt;?xml version="1.0" encoding="US-ASCII"?>
&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		 version="1.0">

&lt;xsl:output method="text"/>

&lt;xsl:template match="V">
   &lt;xsl:for-each select="W">
     &lt;xsl:value-of select="concat('/V/W[',position(),']')"/>
     &lt;xsl:text>
&lt;/xsl:text>
     &lt;xsl:variable name="Xs" select="X"/>
     &lt;xsl:for-each select="$Xs">
       &lt;xsl:if test="generate-id(.)=generate-id($Xs[@...
	 &lt;xsl:value-of select="concat('got X/@...
	 &lt;xsl:text>
&lt;/xsl:text>
       &lt;/xsl:if>
     &lt;/xsl:for-each>
   &lt;/xsl:for-each>
&lt;/xsl:template>

&lt;/xsl:stylesheet>
t:\ftemp>xslt peter.xml peter.xsl con
/V/W[1]
got X/@...
got X/@...
/V/W[2]
got X/@...
got X/@...
got X/@...
/V/W[3]
got X/@...

t:\ftemp>type peter2.xsl
&lt;?xml version="1.0" encoding="US-ASCII"?>
&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		 version="1.0">

&lt;xsl:output method="text"/>

&lt;xsl:key name="Xs" match="X" use="concat(generate-id(..),' ',@...

&lt;xsl:template match="V">
   &lt;xsl:for-each select="W">
     &lt;xsl:value-of select="concat('/V/W[',position(),']')"/>
     &lt;xsl:text>
&lt;/xsl:text>
     &lt;xsl:variable name="Xs" select="X"/>
     &lt;xsl:for-each select="$Xs[generate-id(.)=
	     generate-id(key('Xs',concat(generate-id(..),' ',@...
       &lt;xsl:value-of select="concat('got X/@...
       &lt;xsl:text>
&lt;/xsl:text>
     &lt;/xsl:for-each>
   &lt;/xsl:for-each>
&lt;/xsl:template>

&lt;/xsl:stylesheet>
t:\ftemp>xslt peter.xml peter2.xsl con
/V/W[1]
got X/@...
got X/@...
/V/W[2]
got X/@...
got X/@...
got X/@...
/V/W[3]
got X/@...

t:\ftemp>


--
Registration open for UBL training:    MontrÃ©al, Canada 2006-08-07
Also for XSL-FO/XSLT training:	  Minneapolis, MN 2006-07-31/08-04
Also for UBL/XML/XSLT/XSL-FO training: Varo,Denmark 06-09-25/10-06
World-wide corporate, govt. &amp; user group UBL, XSL, &amp; XML training.
G. Ken Holman		      mailto:gkholman@...
Crane Softwrights Ltd.		http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0	 +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: &lt;mailto:xsl-list-unsubscribe@...
--~--
&lt;/PRE></description>
<dc:creator>G. Ken Holman (gkholman@...)</dc:creator>
<dc:subject>XSL-List</dc:subject>
</item>

<item rdf:about="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173497">
<title>[xsl] Finding the first among equals using XPath</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173497</link>
<description>&lt;PRE>I am sure this is
a hoary old one, but I could not work out the right
runes to achieve it, nor the right keywords to search for to find an
answer

If I have XML like the following:

&lt;V>
  &lt;W>
   &lt;Z/>
       &lt;X Y='0'/>
    &lt;X Y='0'/>
     &lt;X Y='1'/>
   &lt;Z/>
   &lt;/W>
  &lt;W>
   &lt;Z/>
      &lt;Z/>
       &lt;X Y='0'/>
     &lt;X Y='1'/>
      &lt;X Y='2'/>
      &lt;/W>
   &lt;W>
     &lt;X Y='2'/>
      &lt;X Y='2'/>
       &lt;X Y='2'/>
   &lt;Z/>
      &lt;Z/>
	  &lt;/W>
&lt;/V>

I a have a for-each loop over the W elements. Inside the for-each I
want to select one X with each value of Y that exists within that W.

So for the above example, for //W[1] I want to get the first and third
or second and third X elements, for //W[2] I want all three X elements
and for //W[3] I want any one of the X elements, but only one of them.

I hope that bit is clear.

I have run out of ideas now, so I have finally admitted defeat (a hard
thing for an engineer) and am asking for your collective wisdom.

I want a node-set so I can do a for-each on that, so I would prefer to
find a select specifier based on clever use of axes and predicates.

I am stuck with using XSL 1.0

Can anyone help?

Cheers,

Peter

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: &lt;mailto:xsl-list-unsubscribe@...
--~--
&lt;/PRE></description>
<dc:creator>Peter Riocreux (peter.riocreux@...)</dc:creator>
<dc:subject>XSL-List</dc:subject>
</item>

<item rdf:about="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173496">
<title>Re: [xsl] Merging attributes in one XML file with node values  in another (identical structure)</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173496</link>
<description>&lt;PRE>At 10:59 AM
6/22/2006, David wrote:
>&lt;xsl:stylesheet version="1.0" 
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
>&lt;xsl:template match="*">
>  &lt;xsl:copy>
>   &lt;xsl:variable name="n" select="1+count(preceding::*)+count(ancestor::*)"/>
>   &lt;xsl:copy-of select="document('m2.xml')/descendant::*[$n]/@...
>   &lt;xsl:apply-templates/>
>  &lt;/xsl:copy>
>&lt;/xsl:template>
>
>&lt;/xsl:stylesheet>

Blow me away.

Actually I'm consoled a bit since even David's awesomely elegant 
solution works by applying a simple rule (which my non-mathematician 
brain had forgotten) to tell if two nodes are "the same"....

Cheers,
Wendell


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: &lt;mailto:xsl-list-unsubscribe@...
--~--
&lt;/PRE></description>
<dc:creator>Wendell Piez (wapiez@...)</dc:creator>
<dc:subject>XSL-List</dc:subject>
</item>

<item rdf:about="http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173495">
<title>Re: [xsl] Finding the first among equals using XPath</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/XSL-List/3173495</link>
<description>&lt;PRE>> I am stuck with using XSL 1.0

xslt2's for-each-group makes it easier (or at least easier to read) but
any xslt 1 grouping construct would work here. Muenchian grouping (ie
using keys) is the usual approach, but making the keys unique in
subtrees rooted at each W is a bit tiresome, so unless you have 100's of
X below each W I'd just write it directly in XPath

something like

&lt;xsl:for-each select="W">
  &lt;xsl:for-each select="X[not(@...
    something

David


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: &lt;mailto:xsl-list-unsubscribe@...
--~--
&lt;/PRE></description>
<dc:creator>David Carlisle (davidc@...)</dc:creator>
<dc:subject>XSL-List</dc:subject>
</item>

</rdf:RDF>