on 04-26-2007 12:27 PM
hi forum, in message mapping, when i see the XML of the target or source structure i can see the prefix of the qualifiedNameas as ns1 or ns0,
eg., <ns0:MT_sdptest_JMapTest2>
what does that signify....
coz when i made a java mapping programm and tried to test it as an independant program outside XI, taking one XML file as input and one XML file as output, in the code for creating the output structure, i hade created the root element(for the output structure) as
Element rootNode = documentOut.createElementNS("http://zpoc.com.test/sdptest","ns0:MT_sdptest_JMapTest2");
the XML produced gives error as:
"Reference to undeclared namespace prefix: 'ns0'. Error processing resource "
pls help me.....coz i want to intergrate it in a Interface mapping in a scenario
You can remove the namespace prefixes using an XSLT mapping if they are causing problems with applications outside of XI.
Try the following code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.arconw.com/XI/XSLT_Library/XmlNamespacePrefixRemoval"
version="1.0">
<xsl:output method = "xml" />
<xsl:template match="/">
<xsl:apply-templates select="*" mode="remprefix"/>
</xsl:template>
<xsl:template match="*" mode="remprefix">
<xsl:variable name="newname" select="local-name(.)"/>
<xsl:element name="{$newname}" namespace ="{namespace-uri()}">
<xsl:apply-templates mode="copyall" select="@*|comment()|processing-instruction()|text()"/>
<xsl:apply-templates select="*" mode="remprefix"/>
</xsl:element>
</xsl:template>
<xsl:template mode="copyall" match="@*|comment()|processing-instruction()|text()">
<xsl:copy>
<xsl:apply-templates mode="copyall" select="@*|comment()|processing-instruction()|text()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Please assign forum points if you find this useful ***
Thanks,
Paul D.
Message was edited by:
Paul Digance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Pankaj,
Have you seen this weblog:
/people/stefan.grube/blog/2007/02/02/remove-namespace-prefix-or-change-xml-encoding-with-the-xmlanonymizerbean
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Copy the XML into Altova XMLSpy -- mapforce ,and check the validity of xml
Regards
Chilla
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pankaj,
The XML namespace attribute is placed in the start tag of an element and has the following syntax:
xmlns:namespace-prefix="namespaceURI"
<ns0: table xmlns:ns0="http://www.mystudy.com/furniture">
<ns0:name>Coffee Table</ns0:name>
<ns0:width>80</ns0:width>
<nns0:length>120</ns0:length>
</ns0:table>
When a namespace is defined in the start tag of an element, all child elements with the same prefix are associated with the same namespace. Here ns0 represents the namespace "http://www.mystudy.com/furniture".
Hope this gives you clarification regarding namespaces.
**Award points if useful
Cheers,
Santosh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks prabhu and Santosh...
santosh i understood what u said...but help in writing the java code...means
i want to create the root element as:
<ns0:MT_sdptest_JMapTest2 xmlns:ns0="URL/URN">
for this clarify the java statement....is it like this
Element rootNode =
documentOut.createElementNS("http://zpoc.com.test/sdptest","ns0:MT_sdptest_JMapTest2");
rectify this part of code...as this is erroneous
Pankaj,
Try This.
try to create the element firstly and set the attribute using setAttribute method
Element rootNode = docOutput.createElementNS("http://zpoc.com.test/sdptest","ns0:MT_sdptest_JMapTest2");
rootNode.setAttribute("xmlns:ns0", "http://zpoc.com.test/sdptest");
<b>Output is like:
<ns0:Table xmlns:ns0="http://www.w3.org/2001/XMLSchema"/></b>
Cheers,
Santosh
*Award Points if useful
santosh...thanks a lotttttttttttttttttt...
its great...can u pls explain me these two liones
<<<<<<Element rootNode = docOutput.createElementNS("http://zpoc.com.test/sdptest","ns0:MT_sdptest_JMapTest2");
rootNode.setAttribute("xmlns:ns0", "http://zpoc.com.test/sdptest");
>>>>>
means whats the meaning... why do i need to write the second line to setAttribute**
Hi-
Check the namespace name in your XML file .
May be problem with your XML file,check all the syntax.
May be this will be helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ur xml strucutre is not framed good....try to have <ns0:MT_sdptest_JMapTest2 xmlns:ns0="URL/URN"> and test it
Message was edited by:
Prabhu S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
content deleted.
Message was edited by:
Prabhu S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.