xsl-list
[Top] [All Lists]

Re: [xsl] priority of key patterns

2012-11-14 04:24:34
Regarding other use cases for keys in patterns - I tend to do my
renames like this

<xsl:key name="mapNames" match="ren:*/@to" use="../@from"/>
  <xsl:variable name="renames">
    <ren:element from="EmployeeCategory" to="Name"/>
    <ren:element from="PersonName" to="Name"/>
    <ren:element from="FormerlyKnown" to="Name"/>


I would just do:

<xsl:template match="EmployeeCategory | PersonName | FormerlyKnown">
  <Name>


Also top tip regarding this:

       <xsl:apply-templates select="node()|@*"/>

What the union operator | does is de-dupe and sort the nodes into
document order, so by doing "node() | @*" you are giving the processor
more work than "@* | node()" because all the attributes nodes have to
be moved in the sort before the node()s.

If you are using xslt 2.0, then you should use "@*, node()"  (comma
instead of pipe) which returns the nodes exactly the way you specify,
without the de-dupe or sort.

As an example, try

"node() | @*"

vs

"node(), @*"

and

"@* | node() | node()"

vs

"@*, node(), node()"




-- 
Andrew Welch
http://andrewjwelch.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: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--