I have an xsl file which contains some xPath..
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" encoding="UTF-8"/>
<xsl:variable name="ref_num" select="ABCD"/>
<xsl:template match="holiday">
<fromPrice>
<xsl:copy-of select="document('/file/to/path/in/documents/FILE1.xml',/)/dataroot/Tour/RefNo[.='ABHC']/preceding-sibling::AXL "/>
</fromPrice>
</xsl:template>
</xsl:stylesheet>
The Scenario..
The xml file is returning the <fromPrice> values from the FILE1.xml(of which the value is coming from the <AXL> element) file correctly as follows:
FILE1.xml
<Tour>
<Allocation>0</Allocation>
<Available>16</Available>
<AXL>4658</AXL>
<ALO>2195</ALO>
<RefNo>AABC</RefNo>
</Tour>
<Tour>
<Allocation>0</Allocation>
<Available>16</Available>
<AXL>1295</AXL>
<ALO>595</ALO>
<RefNo>ATSS</RefNo>
</Tour>
The problem:
I wanted $ref_num to be passed in the xPath at the "/RefNo[.='ABHC']" so that RefNo contains the value ABCD for the variable $ref_num. That way, if $ref_num changes, I don't have to hard code the xPath at "/RefNo[.='ABHC']" again.
So far I tried the following:
* /RefNo[.=' "+$ref_num+ "'] and that didn't work.{Stylesheet error. Can't Compile}
* /RefNo[.=' \"+$ref_num+ \"'] and that didn't work too.{Stylesheet error. Can't Compile}
* /RefNo[.='+$ref_num+'] and that didn't work too.{Stylesheet error. Can't Compile}