namespace :/

Discussion in 'XML' started by virtual, Apr 15, 2004.

  1. virtual

    virtual Guest

    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
     
    virtual, Apr 15, 2004
    #1
    1. Advertising

  2. virtual wrote:
    > 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 |
    -----------------------
     
    Philippe Poulard, Apr 15, 2004
    #2
    1. Advertising

  3. virtual

    virtual Guest

    > 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 :(
     
    virtual, Apr 15, 2004
    #3
  4. virtual wrote:
    >>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,


    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 |
    -----------------------
     
    Philippe Poulard, Apr 15, 2004
    #4
  5. virtual wrote:
    >>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,


    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 |
    -----------------------
     
    Philippe Poulard, Apr 15, 2004
    #5
  6. 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.
     
    Alex Shirshov, Apr 15, 2004
    #6
  7. virtual

    virtual Guest

    > 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

    > > 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


    basically you are right, but receipt you serve doesn't work. anyway thx for
    good will :)
     
    virtual, Apr 15, 2004
    #7
  8. virtual

    virtual Guest

    > [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
     
    virtual, Apr 15, 2004
    #8
  9. 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.
     
    Alex Shirshov, Apr 15, 2004
    #9
  10. In article <c5lhdq$15m$>, virtual <> wrote:

    >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
     
    Richard Tobin, Apr 15, 2004
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Èý¹â
    Replies:
    1
    Views:
    585
    William F. Robertson, Jr.
    Jul 29, 2003
  2. Replies:
    0
    Views:
    5,146
  3. Anonymous
    Replies:
    3
    Views:
    542
    Ron Natalie
    Aug 18, 2003
  4. Jason Heyes
    Replies:
    1
    Views:
    456
    Woebegone
    Nov 19, 2004
  5. Petter Reinholdtsen
    Replies:
    9
    Views:
    4,397
    Howard
    Nov 29, 2004
Loading...

Share This Page