namespace :/

virtual (archive)

Usenet Archive
Joined
Nov 19, 2003
Messages
12
Reaction score
0
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
 

Philippe Poulard

Usenet Archive
Joined
Dec 20, 2001
Messages
412
Reaction score
0
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)
 

virtual (archive)

Usenet Archive
Joined
Nov 19, 2003
Messages
12
Reaction score
0
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 :(
 

Philippe Poulard

Usenet Archive
Joined
Dec 20, 2001
Messages
412
Reaction score
0
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
 

Philippe Poulard

Usenet Archive
Joined
Dec 20, 2001
Messages
412
Reaction score
0
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 :(
 

Alex Shirshov

Usenet Archive
Joined
Feb 25, 2004
Messages
19
Reaction score
0
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.
 

virtual (archive)

Usenet Archive
Joined
Nov 19, 2003
Messages
12
Reaction score
0
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 :)
 

virtual (archive)

Usenet Archive
Joined
Nov 19, 2003
Messages
12
Reaction score
0
[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
 

Alex Shirshov

Usenet Archive
Joined
Feb 25, 2004
Messages
19
Reaction score
0
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.
 

Richard Tobin

Usenet Archive
Joined
Jan 6, 2000
Messages
4,251
Reaction score
0
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
548,042
Messages
3,104,223
Members
248,131
Latest member
Tonypshaw1

Latest Threads

Top