tags:

views:

157

answers:

3

Hi can i do this in a xslt , and if yes then how..? I have one xml file which contains one element called 'reasonCode' , this reason code is mapped to different 'reasonText' in another xml.What i hae to do is check the 'reasonCode' from first xml and select the corresponding 'reasonText' from second xml.Can i do this using XSLT...if yes then please give me brief idea how..??

+2  A: 

Merge the two files under a new parent tag and send the whole thing through the XSLT.

Abraham Pinzur
but both of my xml have different structure , wont it create a problem.I will use document(abc.xml) command in xslt to merge...
Vivek
A: 

I agree with Abraham's answer. I have written combineNavigableDocuments() methods in PHP, Java and C# to deal with this type of problem. You can also use the XSLT document function but this can lead to unexpected permissions problems in security-aware platforms like .NET.

rasx
+6  A: 

You can use the document() function to access another XML document. For example:

<xsl:template match="reasonCode">
  <xsl:variable name="code" select="."/>
  <xsl:value-of select="document('another.xml')//reasonText[@code = $code]"/>
</xsl:template>
Jukka Matilainen
You even can replace `'another.xml'` with a value of the source document like e.g. an attribute: `document(@href)`.
Boldewyn