Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL and namespace

Status
Not open for further replies.

fuli42

Technical User
Jul 9, 2002
74
0
0
HU
Hi!

I'm new to XML and XSL so...

I'm using Xalan -Java to the transformations. If the root element (the topmost) contains a namespace declaration in the XML file, the XSLT just returns all of the text from the XML file.

If I remove the namespace declaration, then I can use simple <template match=&quot;value&quot;> to replace certain elements for example.

Is this because XSLT 1.0 doesn't work well with namespaces, or something I can correct myself?

Thank you,

Balint
 
You just have to define the namespace in the root element of your XSL file.

<xsl:stylesheet xmlns:xsl=&quot; xmlns:space=&quot; version=&quot;1.0&quot;>

Then use the namespace prefix when matching elements.

<xsl:variable name=&quot;test&quot; select=&quot;//space:test&quot; />

Make sense? The prefix you choose in the XSL doesn't have to be the same as the prefix used in the XML, as long as the value of the declarations are the same.

Uura
~~~~
&quot;Common sense tells you that the world is flat.&quot;
 
>> The prefix you choose in the XSL doesn't have to be the
>> same as the prefix used in the XML, as long as the value
>> of the declarations are the same.



Uh? Could you elaborate, perhaps a small snippet of XML and XSL?

Thanks
-pete
 
Thanx Uura!

So, doeas this mean that I am required to use prefixes? I've just added an xmlns to the root element of the XML file, with no prefix:
<?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-2&quot;?>
<zh xmlns=&quot;xmlns:xsi=&quot;xsi:schemaLocation=&quot; zoldh.xsd&quot;>
.
.
.
</zh>

This what causing major problems. Even if I add the same namespace (with no prefix) to the XSLT file.

THanx,

Balint
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top