Hi,
I´m using an xsl stylesheet to create xsl:fo, which run through a parser outputs pdf. Now the problem I am having is with the namespaces in the xml file.
Beside of the xsi namespace we added a default namespace just in case of future use of this xml by third parties.
Without the default namespace in the xml my xsl workes fine. With the default namespace included in the xml however, without taking any action, my xsl can´t find any of the nodes I'm referring to.
And this I think is odd. The reason of a default namespace is to assign all the nodes without any prefix to this namespace. so it should be logical (to me..), to call them in the xsl by just using their name because they don't have any prefix. But ... this doesn't work.
The only way around this I found, is to include the same namespace in the xsl and add a prefix (lets say a. Then I must refer to my nodes in the xml (who don't have a prefix) by applying the prefix to them.
Puzzeled yet??
So lets say I have a node in my xml called
In my xsl I match the node like this:
With the proper codes around it this workes!! Now I include the following namespace in my xml:
The node "Banking" doesn't have a prefix, so it is assigned to the default namespace. Now if I apply the same xsl it will not find the node!!
But when I modify the xsl:stylesheet node in my xsl like this:
and modify the matching pattern like this:
The code works again!!
Now I like to know if there is a way around this?? I want to use a default namespace in my xml, but preferably I don't want to go through my entire stylesheet to add a prefix to every single node because of this.
I hope someone (you??) can answer this long question,
Jordi Reineman
Cap Gemini Ernst & Young
I´m using an xsl stylesheet to create xsl:fo, which run through a parser outputs pdf. Now the problem I am having is with the namespaces in the xml file.
Beside of the xsi namespace we added a default namespace just in case of future use of this xml by third parties.
Without the default namespace in the xml my xsl workes fine. With the default namespace included in the xml however, without taking any action, my xsl can´t find any of the nodes I'm referring to.
And this I think is odd. The reason of a default namespace is to assign all the nodes without any prefix to this namespace. so it should be logical (to me..), to call them in the xsl by just using their name because they don't have any prefix. But ... this doesn't work.
The only way around this I found, is to include the same namespace in the xsl and add a prefix (lets say a. Then I must refer to my nodes in the xml (who don't have a prefix) by applying the prefix to them.
Puzzeled yet??
So lets say I have a node in my xml called
Code:
<Banking>
In my xsl I match the node like this:
Code:
<xsl:template match="Banking">
With the proper codes around it this workes!! Now I include the following namespace in my xml:
Code:
<Banking xmlns="some.uri.nl">
The node "Banking" doesn't have a prefix, so it is assigned to the default namespace. Now if I apply the same xsl it will not find the node!!
But when I modify the xsl:stylesheet node in my xsl like this:
Code:
<xsl:stylesheet version="1.0" xmlns:a="some.uri.nl"
xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL]
xmlns:fo="[URL unfurl="true"]http://www.w3.org/1999/XSL/Format">[/URL]
and modify the matching pattern like this:
Code:
<xsl:template match="a:Banking">
The code works again!!
Now I like to know if there is a way around this?? I want to use a default namespace in my xml, but preferably I don't want to go through my entire stylesheet to add a prefix to every single node because of this.
I hope someone (you??) can answer this long question,
Jordi Reineman
Cap Gemini Ernst & Young