[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: How to use two xmls for comparing and extracting v
Hi, Thanks a lot for replying. Well you have swapped the file. The following is in the input file from where i have to get the attribute values for some node (here Root node is considered) <Root att1="val1" att2="val2" > And I am having a intermediate file like this. <?xml version="1.0" encoding="UTF-8"?> <Tables> <Table Name="Root"> <Column name="att1"/> <Column name="att2"/> </Table> </Tables> I am to match the name of the Tables/Table@Name='Root' like this first and then if its the same then compare the attritube names of Input file i.e. att1 and att2 with the values in the attributes of node Column of the node Table whose name is Root i.e. if value of the name attribute of Column node in Table node having attribute name="Root" is same as 'name of the attribute of Root node in the input then write the value of attribute of that node from the input file. I hope I have not confused you. I am stuck to do this. Any help would be highly appreciated. Regards, Dipesh Date: Thu, 11 Sep 2003 09:38:54 -0700 (PDT) From: Mukul Gandhi <mukulw3@xxxxxxxxx> Subject: RE: How to use two xmls for comparing and extracting values Hi Dipesh, Your problem description seems a bit ambiguous to me. Hope you can explain more clearly.. To my best understanding, you need an XSL like below -- <?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" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:variable name="Schema" select="document('colHeader.xml')"/> <xsl:template match="/"> <xsl:variable name="x" select="Table/Column[1]/@name" /> <xsl:variable name="y" select="Table/Column[2]/@name" /> <xsl:for-each select="$Schema/Root/@*"> <xsl:if test="name(.) = $x"> `<xsl:value-of select="." /> </xsl:if> <xsl:if test="name(.) = $y"> `<xsl:value-of select="." /> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet> The colHeader.xml file will contain -- <?xml version="1.0" encoding="UTF-8"?> <Root att1="val1" and att2="val2" /> And, the XML file, to which you will apply the above XSL will contain -- <?xml version="1.0" encoding="UTF-8"?> <Table Name="Root"> <Column name="att1"/> <Column name="att2"/> </Table> Regards, Mukul XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|