|
Subject: RE: [xsl] Re: xsl-list Digest 28 May 2008 05:10:01 -0000 Issue 1511 From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Wed, 28 May 2008 17:48:30 +0100 |
> So, your beautifully crafted instruction:
>
> > <xsl:value-of
> > select="for $s in $skus return
> key('sku',$s[document('mySkus.xml')/skus/sku[starts-with(.,$s)
> ]],$root)/name"
> > separator=", "/>
>
> leads me to read more on sequence expressions. I've got to
> go figure out why the <xsl:for-each> was not the correct way,
> how the locally defined <$s> variable works, and how the
> brackets <[]> work.
Some hints:
1. xsl:value-of can output a sequence of values separated by a given
separator (which defaults to a single space)
2. "for $x in SEQ return f($x)" applies some processing to each item in SEQ
in turn, referring to that item as $x
3. $x[predicate], where $x is a single item (which is the case here) returns
either $x or nothing, depending on whether the predicate is true.
4. The predicate here tests whether mySkus.xml contains a sku that starts
with the string $s
5. key('sku', X, $root) searches the tree rooted at $root for a node whose
sku key is equal to X; if X is "nothing" (see 3 above) then key() returns
nothing.
Michael Kay
http://www.saxonica.com/
>
> Interesting that IE and Firefox fail to transform using the
> stylesheet where Saxon does it just fine. I guess they don't
> have built-in version 2 XSLT and/or XPATH features?...
Correct, none of the browsers yet support XSLT 2.0.
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Re: xsl-list Digest 28 Ma, David Carlisle | Thread | Re: [xsl] Re: xsl-list Digest 28 Ma, Andrew Welch |
| Re: [xsl] Sort XML based on Tokeniz, Mukul Gandhi | Date | [xsl] Esoteric XSLT/FXSL question, Justin Johansson |
| Month |