This XSLT has stumped me..

Here should go questions about transforming XML with XSLT and FOP.
Ananya
Posts: 3
Joined: Tue Apr 27, 2010 8:05 am

This XSLT has stumped me..

Post 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
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: This XSLT has stumped me..

Post 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
Ananya
Posts: 3
Joined: Tue Apr 27, 2010 8:05 am

Re: This XSLT has stumped me..

Post 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
Ananya
Posts: 3
Joined: Tue Apr 27, 2010 8:05 am

Re: This XSLT has stumped me..

Post by Ananya »

Also to make it explicit the Transformed.xml is the desired output.
Post Reply