|
[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 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
--- Dipesh Khakhkhar <dkhakhkh@xxxxxxxxxxxxxxx> wrote:
> Hi,
>
> First of all thanks for replying.
>
> I am extremely sorry for writing incorrect desired
> output.
> Actually i would like to have output like
> `val1'val2
>
> I am having input file having node like this
> <Root att1="val1" and att2="val2".
>
> I am having the intermediate file which i
> constructed from input file havin
> structure.
>
> <Table Name="Root">
> <Column name="att1"/>
> <Column name="att2"/>
>
> Now i would like to have output like
> `val1`val2
>
> <xsl:variable name="Schema"
> select="document('colHeader.xml')"/>
>
> In the Schema variable I am having the document root
> of the intermediate file.
>
> I am trying to compare name of the attribute of the
> Root node against the
> value of the Column's naame attribute and if they
> are equal then outputting
> the value of the attribute of the Root node.
>
> I guess I have not confused with the above
> statement.
>
> Sorry once again for giving incorrect output
> information.
>
> Eagerly waiting for reply.
>
> Regards,
> Dipesh
>
>
>
>
> Date: Thu, 11 Sep 2003 09:06:03 +0300
> From: Jarno.Elovirta@xxxxxxxxx
> Subject: RE: How to use two xmls for comparing
> and extracting values
>
> Hi,
>
> > If I have a node like this in my original xml.
> >
> > <Root att1="val1" att2="val2">
> >
> > and the intermediate xml has node like this
> > <Table name="Root">
> > <Column name="att1"/>
> > <Column name="att2"/>
> > </Table>
> >
> > I want to output values like
> > att1`att2.
>
> If you wanted to use the original source directly,
> it's
>
> <xsl:for-each select="Root/@*">
> <xsl:sort select="translate(name(),
> translate(name(), '0123456789', ''), '')"
> data-type="number"/>
> <xsl:if test="not(position() = 1)">`</xsl:if>
> <xsl:value-of select="name()"/>
> </xsl:for-each>
> <xsl:text>.</xsl:text>
>
> and for the intermediate
>
> <xsl:for-each select="Table/Column">
> <xsl:if test="not(position() = 1)">`</xsl:if>
> <xsl:value-of select="@name"/>
> </xsl:for-each>
> <xsl:text>.</xsl:text>
>
> Cheers,
>
> Jarno - Hypnoskull: Biotech Brainkillers
> (Deconstructed)
>
>
> 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
|
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
|

Cart








