Using Saxon parser freebie.
This is a snip of a larger XML file.
<osmChange>
<modify>
<node id="28377390">
<tag k="name" v="Holywell"/>
<tag k="public_transport" v="station"/>
<tag k="railway" v="station"/>
</node>
<node id="168325631">
<tag k="name" v="Whitecraigs"/>
<tag k="public_transport" v="station"/>
<tag k="railway" v="station"/>
</node>
</modify>
</osmChange>
This Xpath:
<xsl:sequence select="$OSM_OSC/osmChange/./modify/(node|way)[tag[@k='railway'][@v='station']]/tag[@k='name']"/>
Returns this, as expected.
<tag k="name" v="Whitecraigs"/>
<tag k="name" v="Holywell"/>
How do I get it to return just the actual names?
Whitecraigs
Holywell
I thought adding /@v to the end would be the solution:
<xsl:sequence select="$OSM_OSC/osmChange/./modify/(node|way)[tag[@k='railway'][@v='station']]/tag[@k='name']/@v"/>
However it returns a long-winded error message:
java.lang.UnsupportedOperationException: copy() applied to attribute node
at net.sf.saxon.tree.tiny.TinyAttributeImpl.copy(TinyAttributeImpl.java:259)
at net.sf.saxon.serialize.UncommittedSerializer.append(UncommittedSerializer.java:207)
at net.sf.saxon.event.ProxyReceiver.append(ProxyReceiver.java:200)
at net.sf.saxon.serialize.PrincipalOutputGatekeeper.append(PrincipalOutputGatekeeper.java:101)
Etc...
<xsl:sequence select="osmChange/modify/(node|way)[tag[@k='railway'][@v='station']]/tag[@k='name']/@v/string()"/>. The error seems odd but it is hard to tell whether it is caused by trying to output the attribute nodes outside of a parent element container or by some bug in Saxon.xsl:sequenceselecting the two attribute nodes. But try to access the string values with the shown/@v/string()and you should get your two valuesWhitecraigs Holywell, I think, even with that bug/quirk in Saxon.xsl:value-ofinstead ofxsl:sequence.xsl:sequenceinstruction would work if it were a child of some element (well, sort of work: an element cannot have two attributes with the same name, so the result would be something like<elem v="Whitecraigs"/>). Trying to output attributes without a parent element should result in an error, though I am not convinced that's the best error message.