Subject: [xsl] How can i compare tags in two xml files From: "Sudhakar Bijjam" <sbijjam@xxxxxxxxxxxxxxxxxxx> Date: Fri, 14 Jun 2002 16:30:33 +0530 |
Hi, I want to compare tags of two xml files and if it matches needs to display the label name of the tag selected from second xml file in HTML form. My xml files are: XMLTemplate file1: <xml> <order> <purchase> <pon>783</pon> </purchase> </order> <sales> <sod1>-----</sod1> <sod2>-----</sod2 > <pon>86578</pon> </sales> </xml> XMLTemplate file2: <xml> <order label = "order"> <purchase label= "purchase/> <pon label = "pon"/> </purchase> </order> <sales label = "sales"> <sod1 label = "sod1"/ <sod2 label = "sod2"/ <pon label = "salespon"/>> </sales> </xml> I have written code like this: <xsl:stylesheet version="1.0"> <!-- calling xmlTemplatefile2.xml in xmlTemplatefile1--> <xsl:variable name="template" select="document('xmlTemplatefile2.xml')"/> <!--Template will match root node of xmlTemplatefile1--> <xsl:template match="/"> <html> <title>Purchase Order Form</title> <body> <table align="center" border="1" width="100%" > <xsl:variable name="tagname" select="local-name()"/> <xsl:for-each select="$template"> <xsl:if test="descendant::*[local-name() = $tagname]"> <xsl:for-each select="descendant::*[local-name() = $tagname]"> <xsl:if test="position() = 1"> <!------displaying the label of the tag in HTML-------> <xsl:value-of select="@label"/> </xsl:if> </xsl:for-each> </xsl:if> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> If i execute my code i am getting problem with repetitive tags like 'pon'.I am getting wrong label name for the 'pon' tag defined under 'sales'. Is it possible to compare the tags like this way which i had defined below? XMLTemplate1 XMLTemplate2 xml - xml xml/order - xml/order xml/order/purchase - xml/order/purchase xml/order/purchase/pon- xml/order/purchase/pon How would i get full path of the each tag in XMLTemplate1 and XMLTemplate2? Thanks for any help on this, Sudhakar XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Yet Another Flat File to , Paul Bunkham | Thread | RE: [xsl] Yet Another Flat File to , McNally, David |
Re: [xsl] Format number problem, Andreas Hess | Date | Re: [xsl] Unwrapping trees, Norman Walsh |
Month |