namespace :/

V

virtual

I have xml document like this:

<?xml version="1.0" encoding="UTF-8" ?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<response>
<result code="2303">
<msg lang="pl">foo message</msg>
<value>
<name xmlns="domain">fooo.com</name>
</value>
<extValue>
<value>
<reasonCode xmlns="">9060</reasonCode>
</value>
</extValue>
</result>
</response>
</epp>

I can succesfully process with Xalan all its nodes, but this "weird" one:

<name xmlns="domain">fooo.com</name>

what the hell its namespace is?? in other words I need to know how looks the
"match" attribute for it ?
match="name"
match="domain:name"
.....
??
only match="*" can get it, but of course it is no solution
I have no idea to get this working :(( Please help.

thx
 
P

Philippe Poulard

virtual said:
I have xml document like this:

<?xml version="1.0" encoding="UTF-8" ?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<response>
<result code="2303">
<msg lang="pl">foo message</msg>
<value>
<name xmlns="domain">fooo.com</name>
</value>
<extValue>
<value>
<reasonCode xmlns="">9060</reasonCode>
</value>
</extValue>
</result>
</response>
</epp>

I can succesfully process with Xalan all its nodes, but this "weird" one:

<name xmlns="domain">fooo.com</name>

what the hell its namespace is?? in other words I need to know how looks the
"match" attribute for it ?
match="name"
match="domain:name"
....
??
only match="*" can get it, but of course it is no solution
I have no idea to get this working :(( Please help.

thx

hi,

i assume that you are using xslt...

you *must* define a prefix in your stylesheet to match an element bound
to a namespace, even if it is unprefixed in the source document, like this :
match="foo:name"
if the host element or one of its ancestor declares xmlns:foo="domain"

if your are not using xslt and your matching pattern is processed by an
xpath engine, see the documentation of your tool for binding prefixes to
namespace uris (because you 'll have to use a prefix too)
--
Cordialement,

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

virtual

i assume that you are using xslt...

yes you're right
you *must* define a prefix in your stylesheet to match an element bound
to a namespace, even if it is unprefixed in the source document, like this :
match="foo:name"
if the host element or one of its ancestor declares xmlns:foo="domain"

i know and it's already done. i declare xmlns="domain" in xsl stylesheet,
but althought it doesn't work. and notice that without this declaration xslt
processor would raise exception i suppose, anyway it is not the way to solve
this problem, this node is still anmatched :(
 
P

Philippe Poulard

virtual said:
yes you're right




i know and it's already done. i declare xmlns="domain" in xsl stylesheet,

try it with a prefix !
xmlns:foo="domain"

and

match="foo:name"

it will work
but althought it doesn't work. and notice that without this declaration xslt
processor would raise exception i suppose, anyway it is not the way to solve
this problem, this node is still anmatched :(

the declaration you defined doesn't use a prefix; it applied only on
litteral elements produced in the output tree; if you want to apply a
namespace uri on xpath expressions and patterns, you really *must* use a
*prefix*, like shown above

--
Cordialement,

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

Philippe Poulard

virtual said:
yes you're right




i know and it's already done. i declare xmlns="domain" in xsl stylesheet,
but althought it doesn't work. and notice that without this declaration xslt
processor would raise exception i suppose,

no, the processor don't know which entries are supposed to be processed;
if a "wrong" document is used to feed a stylesheet, its elements won't
be matched (howver, the default templates may be applied)

anyway it is not the way to solve
this problem, this node is still anmatched :(


--
Cordialement,

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

Alex Shirshov

Hello, virtual!
You wrote on Thu, 15 Apr 2004 10:37:21 +0200:


[Sorry, skipped]

<xsl:template match="n:name" xmlns:n="domain">
....
</xsl:template>

With best regards, Alex Shirshov.
 
V

virtual

try it with a prefix !
xmlns:foo="domain"

i wrote that with mistake in hurry, of course it should be with prefix and
of course it was (in document)
and

match="foo:name"

it will work

no it would not
the declaration you defined doesn't use a prefix; it applied only on
litteral elements produced in the output tree; if you want to apply a
namespace uri on xpath expressions and patterns, you really *must* use a
*prefix*, like shown above

basically you are right, but receipt you serve doesn't work. anyway thx for
good will :)
 
V

virtual

[Sorry, skipped]
<xsl:template match="n:name" xmlns:n="domain">
...
</xsl:template>

With best regards, Alex Shirshov.

yeaaah!!!! you are great Alex :) it definetely works, but to be honest I
would never get to know this trick, really.
it is pretty sick namespace stuff and I read (let's say "watched") all
books form o'reilly/wrox/maning/whatever I had and found nothing about such
a case like mine

thanx anyway, cheers
 
A

Alex Shirshov

Hello, virtual!
You wrote on Thu, 15 Apr 2004 11:24:28 +0200:


[Sorry, skipped]

v> yeaaah!!!! you are great Alex :) it definetely works, but to be honest I
v> would never get to know this trick, really.
v> it is pretty sick namespace stuff and I read (let's say "watched") all
v> books form o'reilly/wrox/maning/whatever I had and found nothing about
v> such a case like mine

XSL(T) is xml, so all rules of xml specification (encoding, naming), xml
namespace specification and other related papers apply to it.

With best regards, Alex Shirshov.
 
R

Richard Tobin

i know and it's already done. i declare xmlns="domain" in xsl stylesheet,
but althought it doesn't work. and notice that without this declaration xslt
processor would raise exception i suppose, anyway it is not the way to solve
this problem, this node is still anmatched :(

The default namespace declaration is not used when interpreting XPath
expressions. To refer to an element in a namespace, you must use a
prefix in the stylesheet.

-- Richard
 

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,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top