Page 1 of 1

This XSLT has stumped me..

Posted: Tue Apr 27, 2010 8:43 am
by Ananya
Hi,

I have a complex XSLT transformation and I am trying to figure out how to proceed with.
I am attempting to collect the information associated to a particular PortId. However this information is distributed across various elements as indicated below.
In the example below the information for port_id2 is across two <Map> elements. How would I extract the DOMAIN_ID associated to the same port_ids and transform them into the <ServicePort> element in the output xml.

Input.xml -

<AttributeList>
<Map>
<entry>
<key>PortId</key>
<value>port_id1</value>
</entry>
<entry>
<key>DOMAIN_ID</key>
<value>one</value>
</entry>
</Map>
<Map>
<entry>
<key>PortId</key>
<value>port_id2</value>
</entry>
<entry>
<key>DOMAIN_ID</key>
<value>13</value>
</entry>
</Map>
<Map>
<entry>
<key>PortId</key>
<value>port_id2</value>
</entry>
<entry>
<key>DOMAIN_ID</key>
<value>14</value>
</entry>
</Map>
</AttributeList>

Transformed.xml -

<?xml version="1.0"?>
<ServicePorts>
<ServicePort>
<PortId>port_id1</PortId>
<ServicePortDetails>
<VlanId>one</VlanId>
</ServicePortDetails>
</ServicePort>
<ServicePort>
<PortId>port_id2</PortId>
<ServicePortDetails>
<VlanId>13</VlanId>
</ServicePortDetails>
<ServicePortDetails>
<VlanId>14</VlanId>
</ServicePortDetails>
</ServicePort>
</ServicePorts>
<BandwidthSubscriptions>

Apologies for loosing the indentation but I couldn't get it right :(.
Thanks in advance.

Regards
Ananya

Re: This XSLT has stumped me..

Posted: Tue Apr 27, 2010 10:24 am
by sorin_ristache
Hello,

Maybe the following two tutorials can help you to get started with XSLT templates and XPath expressions:

http://www.w3schools.com/xsl/xsl_intro.asp

http://www.w3schools.com/xpath/default.asp


Regards,
Sorin

Re: This XSLT has stumped me..

Posted: Tue Apr 27, 2010 10:54 am
by Ananya
Hi Sorin,

Thanks for the reply.

Though I am a newbie to XSLT but I have some idea about it.
I require help in solving this specific issue.
If you are good at it can you help me out with a solution.

Regards
Ananya

Re: This XSLT has stumped me..

Posted: Tue Apr 27, 2010 10:56 am
by Ananya
Also to make it explicit the Transformed.xml is the desired output.