on 10-30-2010 6:03 AM
Hi,
I need to create more than one xml file from one source xml file using xslt mappings in file to file scenario.
Can you please let me know how this can be achieved.
Thanks,
Rajesh
Rajesh,
If you must use the XSL Transformation then you can find a nice simple example here. It's based on the Xalan XSLT Processor which to my knowledge is incorporated in PI7.1. I've not actually tried this but it makes for an interesting mapping case so please let us know the results:
[XSLT Split for multiple XML file output|http://abbeyworkshop.com/howto/xslt/xslt_split/index.html]
The XSL file will require a namespace addition:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:redirect="http://xml.apache.org/xalan/redirect" extension-element-prefixes="redirect" version="1.0">
The redirect prefix is used for the write tags in the XSL file.
The details cover the transformation of the source file:
1:<student_list>
2: <student id="1">
3: <name>George Washington</name>
4: <major>Politics</major>
5: <phone>312-123-4567</phone>
6: <email>gw_at_example.edu</email>
7: </student>
8: <student id="2">
9: <name>Janet Jones</name>
10: <major>Undeclared</major>
11: <phone>311-122-2233</phone>
12: <email>janetj_at_example.edu</email>
13: </student>
14: <student id="3">
15: <name>Joe Taylor</name>
16: <major>Engineering</major>
17: <phone>211-111-2333</phone>
18: <email>joe_at_example.edu</email>
19: </student>
20:</student_list>
Using this transformation:
2:<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3: xmlns:redirect="http://xml.apache.org/xalan/redirect"
4: extension-element-prefixes="redirect"
5: version="1.0"
6:>
7:<xsl:output method="xml"/>
8:
9:<xsl:template match="/">
10: <xsl:apply-templates />
11:</xsl:template>
12:
13:<xsl:template match="student_list">
14: <xsl:apply-templates />
15:</xsl:template>
16:
17:<xsl:template match="student">
18: <xsl:variable name="filename" select="concat(@id,'.xml')" />
19: <redirect:write select="$filename">
20: <student id="{@id}">
21: <xsl:apply-templates />
22: </student>
23: </redirect:write>
24:</xsl:template>
25:
26:<xsl:template match="name | major | phone | email">
27: <xsl:copy-of select="." />
28:</xsl:template>
29:
30:</xsl:stylesheet>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You would be able to accomplish it using graphical mapping itself(multi-mapping) if there is no other reason for going to XSLT.
check this document,
http://help.sap.com/saphelp_nw04/helpdata/en/21/6faf35c2d74295a3cb97f6f3ccf43c/content.htm
regards,
francis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
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.