On 21/11/2011 16:34, Merrilees, David wrote:
Hi
I'm stuck with an Xpath. How can I select child nodes with the same name? The
names are arbitrary. So far I have this, which does not work:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<xsl:template match="/">
<test>
your desired output had <array> here?
<xsl:apply-templates select="array/node()[name() = name(../node())]" />
../node() selects all the children of your parent including yourself, so
this would not work even if you modified it to call name(0 on each node
sparately.
</test>
</xsl:template>
<xsl:template match="node()">
<xsl:copy-of select="*" />
</xsl:template>
* copies the child elements but your examples only have child text so
uou would lose the contents of each item.
</xsl:stylesheet>
Input
<array>
<item/>
your desired result does not have this empty item even though it shares
the name "item", is there an additioanl unstated rule that empty
elements be filtered, or should this be in the output?
<nope/>
<item>4</item>
<item>5</item>
<wibble/>
<item>six</item>
<wibble>stuff</wibble>
<item>item</item>
<no/>
</array>
as with all grouping, this would be easier in xslt2, but assuming you do
need 1, something like
<xsl:key name="n" match="*" use="concat(generate-id(..),name())"/>
select="array/*[key('n',concat(generate-id(..),name())[2]]" />
David
Desired output
<array>
<item>4</item>
<item>5</item>
<wibble/>
<item>six</item>
<wibble>stuff</wibble>
<item>item</item>
</array>
Thanks
-----Original Message-----
From: Merrilees, David
Sent: 18 October 2011 16:46
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] required parameter
It returns
<form id="fLanguage" action="/en-GB/Language/Set" method="post"></form>
Thanks
This is a confidential email. Tesco may monitor and record all emails. The
views expressed in this email are those of the sender and not Tesco.
Tesco Stores Limited
Company Number: 519500
Registered in England
Registered Office: Tesco House, Delamare Road, Cheshunt, Hertfordshire EN8 9SL
VAT Registration Number: GB 220 4302 31
--~------------------------------------------------------------------
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>
--~--
________________________________________________________________________
This e-mail has been scanned for all viruses by Star.
________________________________________________________________________
--
google plus: https:/profiles.google.com/d.p.carlisle
________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________
--~------------------------------------------------------------------
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>
--~--