on 04-22-2014 12:11 PM
Hi Experts!
How can achive this through XSLT Mapping???
My Source XML file :
--<ROOT>
--<A>
<A1> </A1>
<A2> </A2>
</A>
--<A>
<A1> </A1>
<A2> </A2>
--<X>
<X1> </X1>
<X2> </X2>
</X>
--<X>
<X1> </X1>
<X2> </X2>
</X>
</A>
--<B>
<BB> </BB>
<BB> </BB>
--<B1>
<BB1> </BB1>
<BB1> </BB1>
</B1>
--<B2>
<BB2> </BB2>
<BB2> </BB2>
</B2>
--<B3>
<BB3> </BB3>
<BB3> </BB3>
</B3>
</B>
</ROOT>
My Target XML file should be like this :
--<ROOT
--<A>
<A1> </A1>
<A2> </A2>
</A>
--<A>
<A1> </A1>
<A2> </A2>
</A>
--<X>
<X1> </X1>
<X2> </X2>
</X>
--<X>
<X1> </X1>
<X2> </X2>
</X>
--<B>
<BB> </BB>
<BB> </BB>
</B>
--<B1>
<BB1> </BB1>
<BB1> </BB1>
</B1>
--<B2>
<BB2> </BB2>
<BB2> </BB2>
</B2>
--<B3>
<BB3> </BB3>
<BB3> </BB3>
</B3>
</ROOT>
So How can I write .Xsl file to achive this.
Help me to get the output quickly.
Suggestions and Tips Please!
Hello,
It is not perfect but it might help achieving what you want. I have two XSLTs that you have to run in order. first run this one to copy the wanted nodes
into one hierarchy higher:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ROOT">
<ROOT>
<xsl:apply-templates/>
<xsl:apply-templates select="/ROOT/A/X"/>
<xsl:apply-templates select="/ROOT/B/B1 | /ROOT/B/B2 | /ROOT/B/B3"/>
</ROOT>
</xsl:template>
</xsl:stylesheet>
Now run this one to get rid of the ones not needed anymore:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/ROOT/A/X"/>
<xsl:template match="/ROOT/B/B1 | /ROOT/B/B2 | /ROOT/B/B3"/>
</xsl:stylesheet>
They are both using the "identity-transform".
Best regards,
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Peter,
This code is very short and simple. but it makes the correct output what i want. thankq for ur answer.
I am new to PI. So give some ideas to learn xslt mapping concept and XSLT elemnts.
mention only easy way of understanding links and website.
or else give ur own tips how to learn clearly about this XSLT concepts
Hello Jeevitha,
I can recommend www.stackoverflow.com if you have specific questions to XSLT.
There you also find this interesting thread with useful XSL tutorials:
http://stackoverflow.com/questions/3511759/where-can-i-find-a-good-tutorial-on-xslt-files
Also, these pages are probably helpful:
www.devguru.com/technologies/xslt/home
www.jenitennison.com/xslt/index.xml
Related to SAP PI:
Best regards,
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.