[xsl] attribute values as name value pair

Subject: [xsl] attribute values as name value pair
From: "Tracy" <amit.shukla@xxxxxxxxxxx>
Date: Thu, 26 Feb 2004 18:20:45 -0800
Ok this is a tough one. Haven't been able to find a solution for the last
two days.

I have two XML that contains attribute nodes and I need to produce an XML
that creates nodes with attributes name from one XML and its values from the
other one.

First XML

        <row trade ="10.6" code="Z101" description="Zee Hiber Tools"
price="60.66" weight="200" value="100.66" />
        <row trade ="10.9" code="Z102" description="Zee Plant Tools"
price="97.46" weight="200" value="76.00" />

Second XML

                <column name="code" value="Code" />
                <column name="description" value="Desc" />
                <column name="price" value="Price" />
                <column name="weight" value="Weight" />
                <column name="value" value="Value" />

Now I want that for every row of the first XML, the number of rows generated
should be the number of column nodes. Also, should have the name as the
attribute name and value of its respective match in the first XML. The
output has to look like this:

        <row id="1" key="Code" value="Z101" />
        <row id="2" key="Desc" value="Zee Hiber Tools" />
        <row id="3" key="Price" value="60.66" />
        <row id="4" key="Weight" value="200" />
        <row id="5" key="Value" value="100.66" />

        <row id="6" key="Code" value="Z102" />
        <row id="7" key="Desc" value="Zee Plant Tools" />
        <row id="8" key="Price" value="97.46" />
        <row id="9" key="Weight" value="200" />
        <row id="10" key="Value" value="76.00" />

So you see, for every row in the first XML, there are 5 nodes in the output
(same as number of cloumn nodes) with id as number generated,  key as
"Second XML's value's value" and value as "attribute value" from First XML
where attribute's name is the same as the "name" attribute of the Second XML
. Some of the attributes of the first XML are ignore (like trade). Isn't it
complicated ? I know that there will be two xsl:for-each loop in it but I
still can't figure it out.

Please help me.

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

Current Thread