Krishn60 Posted March 13, 2009 Share Posted March 13, 2009 HiI have this requirement - 2 Files, Both should be linked and I should create a Text file as stated belowFirst XML file<HEAD1> <INFORM Number="46" Name="TARAN" Age="46" /> <INFORM Number="1339" Name="Bob" Age="44" /> <INFORM Number="887" Name="Debra" Age="35" /></HEAD1>Second XML file<STAND1> <ACTIVITY Number="46" Name="Gymnastics"> <SUBACT> Bar </SUBACT> <SUBACT> Pole </SUBACT> <SUBACT>Ring </SUBACT> </ACTIVITY> <ACTIVITY Number="57" Name="Swimming" /> <ACTIVITY Number="146" Name="Skying"/></STAND1>Output that I am expecting (using the link of "Number" between First and Second File) isTARAN|46|PoligonDobleBREATH|BarTARAN|46|PoligonDobleBREATH|PoleTARAN|46|PoligonDobleBREATH|Ring===============================================================I know, I can do it taking the second file and chaining it to the first file. But the XML file that I have given is the simplest form of what I have here. I have do achieve the result taking the first file and then chaining it to the 2nd file. Please let me know how to do that.ThanksKrishnan. Link to comment Share on other sites More sharing options...
boen_robot Posted March 14, 2009 Share Posted March 14, 2009 You can always use document() to get the other document, regardless of which document is the "other".If I understand you correctly, this should work for you: <?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" encoding="utf-8" /> <xsl:template match="text()" /> <xsl:template match="ACTIVITY[SUBACT]"> <xsl:variable name="number" select="@Number" /> <xsl:variable name="name" select="document('first.xml')//INFORM[@Number=$number]/@Name" /> <xsl:for-each select="SUBACT"> <xsl:text><xsl:value-of select="$name" />|<xsl:value-of select="$number" />|PoligonDobleBREATH|<xsl:value-of select="." /></xsl:text> </xsl:for-each> </xsl:template></xsl:stylesheet> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.