namespace problem with XSLT

T

Trygve

I'm trying to convert a XML-document using XSLT. Depending on the source
file (the XML-document)
the conversion is either correct or incorrect. If the first tag in the
document contains an non
empty xmlns attribute:

<Meldekorttype xmlns="http://myhost.com/mk_print_meldekort.xsd">
<tag1>Value1</tag1>
<tag2>Value2</tag2>
</Meldekorttype>

the conversion is incorrect, i.e. only the values of each tag (Value1,
Value2) are printed to the output.
If I remove the xmlns attribute of the first tag:

<Meldekorttype xmlns="">
<tag1>Value1</tag1>
<tag2>Value2</tag2>
</Meldekorttype>

the conversion is correct.

In my application I'm not allowed to remove the xmlns attribute, so I'm
stuck. Does anyone
know what causes the problem, or how I can solve it?

Thanks in advance.

Trygve
 
P

Philippe Poulard

Trygve said:
I'm trying to convert a XML-document using XSLT. Depending on the source
file (the XML-document)
the conversion is either correct or incorrect. If the first tag in the
document contains an non
empty xmlns attribute:

<Meldekorttype xmlns="http://myhost.com/mk_print_meldekort.xsd">
<tag1>Value1</tag1>
<tag2>Value2</tag2>
</Meldekorttype>

the conversion is incorrect, i.e. only the values of each tag (Value1,
Value2) are printed to the output.
If I remove the xmlns attribute of the first tag:

<Meldekorttype xmlns="">
<tag1>Value1</tag1>
<tag2>Value2</tag2>
</Meldekorttype>

the conversion is correct.

In my application I'm not allowed to remove the xmlns attribute, so I'm
stuck. Does anyone
know what causes the problem, or how I can solve it?

Thanks in advance.

Trygve

hi,

did you declare the namespace with a prefix in your xslt file ?
try it !
--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
 
P

Philippe Poulard

Trygve said:
Hi,

Thanks for the answer. I *think* I've declared it in my xslt file, but I'm
not sure since I'm a newbie to xslt.

This is the start of my xml-file:

<Meldekorttype xmlns="http://myhost.com/mk_print_meldekort.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://myhost.com/arena/mk_print_meldekort.xsd
http://myhost.com/public/xsd/mk_print_meldekort.xsd">
<Meldekorttypekode>01</Meldekorttypekode>
<AB-post>A</AB-post>
.
.
</Meldekorttype>

And this is the start of my xslt-file:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:foo="http://myhost.com/mk_print_meldekort.xsd"
^^^^
you MUST define a prefix here
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://myhost.com/arena/mk_print_meldekort.xsd
http://myhost.com/public/xsd/mk_print_meldekort.xsd" version="1.0">
<xsl:eek:utput method="text"/>
.

.
</xsl:stylesheet>

Is this correct or have I forgotten something?

Thanks in advance!

Best regards
Trygve


--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
 
T

Trygve

Dear Phillippe!

You pointed at the error in your first reply. I forgot to declare the
namespace with a prefix
in my xslt file. Following your advice made it work. Thanks a lot!!!

I can continue my work after two days of banging my head against the wall.
Thanks again :)

Best regards,
Trygve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top