I can not formulate it correctly, better with an example.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<foo>
<bar id="someId" class="someClass"/>
<buz class="someClass" id="someId"/>
<ololo class="someClass"/>
<test id="someId"/>
</foo>
XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/*/*">
<xsl:value-of select="@id | @class"/><xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
Result:
someId
someClass
someClass
someId
What I need
I need the "priority" of the attributes to remain specified in my xpath expression.
So, if we call an @id | @classexpression with two operands, I need the attributes to be taken not in the order of the document, but in the order in which the two expressions were specified in the expression.
So, the result should be :
someId
someId
someClass
someId
@classshould be taken only if @idabsent.
I know that this can be done with conditional logic, but I'm really interested in a short solution because it is common and used as an attribute value template .
, The Elegant One.
, XPath 1.0.