Stephen,
"contains" seems to work for me ... (with xpath++ tool [1]).
I used first example from [2].
Although XPath only provides "starts-with()" you can simulate "ends-with()"
you seem to need by adding a forbidden character (eg. '<' for attribute
values, see [3]).
$ xpath++ "//xs:element[contains(@name,'born')]" schema1.xml
-------------------------------------------------------------------------------
<xs:element xmlns:xs="http://www.w3.org/2001/XMLSchema" name="dateborn"
type="xs:date"/>
$
$ xpath++ "//xs:element[contains(concat(@name,'<'),'born<')]" schema1.xml
-------------------------------------------------------------------------------
<xs:element xmlns:xs="http://www.w3.org/2001/XMLSchema" name="dateborn"
type="xs:date"/>
$
$ cat schema1.xml
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="fname" type="xs:string"/>
<xs:element name="lname" type="xs:string"/>
<xs:element name="age" type="xs:nonNegativeInteger"/>
<xs:element name="dateborn" type="xs:date"/>
</xs:schema>
$
[1]
https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14511881�
[2]
http://www.w3schools.com/schema/el_element.asp
[3]
http://www.w3.org/TR/REC-xml/#NT-AttValue
Mit besten Gruessen / Best wishes,
Hermann Stamm-Wilbrandt
Developer, XML Compiler, L3
WebSphere DataPower SOA Appliances
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
From: "Etheridge, Stephen" <stephen(_dot_)etheridge(_at_)logica(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Date: 08/18/2010 09:58 AM
Subject: [xsl] Selecting all elements which have an attribute that
matches a given pattern
Hi all and apologies if this has been dealt with previously, I searched
the archives and FAQ but did not find anything that was close to my
problem:
I have an XML file (a schema in fact) that is many thousands of lines
long and I need to edit it (i.e transform it). There are numerous
elements of type <xs:element> all of which have a "name" attribute.
Some of those name attributes end with the string "List", e.g.
"MilkTypeList". For those elements, I want to apply a template to add
an additional <xs:element>. I am having great trouble crafting the
correct "match" for my <xsl:template>. I have tried contains() and
matches() but my editor (Oxygen) states that those cannot be used as a
pattern and my reading supports that. Can anyone help?
Thanks
Stephen
Please help Logica to respect the environment by not printing this email /
Pour contribuer comme Logica au respect de l'environnement, merci de ne pas
imprimer ce mail / Bitte drucken Sie diese Nachricht nicht aus und helfen
Sie so Logica dabei, die Umwelt zu schützen. / Por favor ajude a Logica a
respeitar o ambiente nao imprimindo este correio electronico.
This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--