on 06-08-2006 10:27 AM
Hi all,
I try to make a mapping using XSLT and get the exception: Prefix not mapped: ns0.
I wrote a simple xslt-script:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://me.home.com">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="//XIFCollection">
<Start>
<xsl:for-each select="ns1:XIFTest">
<Found>
<xsl:number format="1"/>
</Found>
</xsl:for-each>
</Start>
</xsl:template>
</xsl:stylesheet>
Using this input XML:
<?xml version="1.0" encoding="UTF-8"?>
<XIFCollection >
<ns0:XIFTest xmlns:ns0="http://me.home.com">
<IFControl>
<MeldungsId>1</MeldungsId>
</IFControl>
<XTest>
</XTest>
</ns0:XIFTest>
<ns0:XIFTest xmlns:ns0="http://me.home.com">
<IFControl>
<MeldungsId>2</MeldungsId>
</IFControl>
<XTest>
</XTest>
</ns0:XIFTest>
</XIFCollection>
In XML-Spy I get the following output:
<?xml version="1.0" encoding="UTF-8"?>
<Start xmlns:ns1="http://me.home.com">
<Found>1</Found>
<Found>2</Found>
</Start>
What I expected.
But using XI or the XML-Toolkit XI30xslt I get the exception:
java.lang.Exception: XMLParser: Prefix 'ns0' is not mapped to a namespace.
I tried everything and searched all dokumentation but have no idea.
Anyone with an idea?
Thanks
Hi Denise,
i didnt test it, but i'm optimistic you can solve your problem if you additional declare that prefix in the stylesheet element:
xmlns:ns0="http://me.home.com"
Regards,
Udo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you need to chage as Udo said
but also the other ns0 one:
check this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://me.home.com">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="//XIFCollection">
<Start>
<xsl:for-each select="ns0:XIFTest">
<Found>
<xsl:number format="1"/>
</Found>
</xsl:for-each>
</Start>
</xsl:template>
</xsl:stylesheet>
BTW
it works in Stylus Studio now
Regards,
michal
Thanks for the fast replies.
I had the same ideas and tried them before. But that doesnt help.
The only way of getting this to run is deleting the namespaces or set only the root element of the XML-Input to a namespace.
But I can't see why it is not working like I described. I think this is XML-conform?
Thanks so far
There's a namespace conceptual error here.
If you want your xml tags, all of them, to belong to a certain namespace, you have two ways of doing it.
1. you can reference that namespace prefix before every tag, separated by ':';
2. you can just use the xmlns attribute in the root tag, and all the child tags inserted in that root tag will also belong to that namespace; but in this case, you don't need to use the prefix.
So, just remove the 'ns0' prefix of the XIFTest tags in your input xml. Or put ns0 prefix in all of it's child tags.
Regards,
Henrique.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
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.