[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

Subject: RE: How to use two xmls for comparing and extracting values
From: Mukul Gandhi <mukulw3@xxxxxxxxx>
Date: Thu, 11 Sep 2003 19:09:25 -0700 (PDT)
how to test xmls
Hi Dipesh,
  To my best understanding, below is the required
XSL..

<?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:if test="$Schema/Tables/Table/@Name =
'Root' ">
       <xsl:for-each select="Root/@*">
	   <xsl:if test="name(.) =
$Schema/Tables/Table/Column[1]/@name">
            `<xsl:value-of select="."/>
	   </xsl:if>
	   <xsl:if test="name(.) =
$Schema/Tables/Table/Column[2]/@name">
            `<xsl:value-of select="."/>
	   </xsl:if>
        </xsl:for-each>
     </xsl:if>
</xsl:template>
</xsl:stylesheet>


Regards,
Mukul

--- Dipesh Khakhkhar <dkhakhkh@xxxxxxxxxxxxxxx> wrote:
> 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
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.