Fixed/default attributes in Xerces: Namespace prefix missing?...

Discussion in 'XML' started by VanOrton, Nov 30, 2005.

  1. VanOrton

    VanOrton Guest

    Hi all,

    When XercesDOMParser parses an XML document with a Schema instance, by
    default it
    adds all missing default and fixed attributes. I have the impression
    though that it misses the
    namespace prefices... I'm using Xerces 2.5.0.

    Here's a document parsed by Xerces:

    <?xml version="1.0" encoding="UTF-8"?>
    <mads xmlns="http://www.loc.gov/mads/"
    xmlns:mods="http://www.loc.gov/mods/v3"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.loc.gov/mads/ mads.xsd">
    <authority type="simple"/>
    </mads>

    The "type" attribute in element "authority" was automatically added by
    the parser...

    But "type" is defined in xlink (namespace
    "http://www.w3.org/1999/xlink"). Shouldn't
    Xerces have added its prefix in front?? (xlink:type="simple") ??? I
    think there is a
    problem here... Anybody experienced it? Or anybody can help?

    "mads" schema has: attributeFormDefault="unqualified"

    You can find the above Schemas at:

    http://www.loc.gov/mads/ : http://www.loc.gov/standards/mads/mads.xsd
    http://www.loc.gov/mods/v3 :
    http://www.loc.gov/standards/mods/v3/mods-3-0.xsd
    http://www.w3.org/1999/xlink :
    http://www.loc.gov/standards/mods/xlink.xsd

    Thank you all in advance...

    Nicolas
    VanOrton, Nov 30, 2005
    #1
    1. Advertising

  2. VanOrton wrote:


    > When XercesDOMParser parses an XML document with a Schema instance, by
    > default it
    > adds all missing default and fixed attributes. I have the impression
    > though that it misses the
    > namespace prefices... I'm using Xerces 2.5.0.


    Is that Xerces Java or Xerces C++?

    > Here's a document parsed by Xerces:
    >
    > <?xml version="1.0" encoding="UTF-8"?>
    > <mads xmlns="http://www.loc.gov/mads/"
    > xmlns:mods="http://www.loc.gov/mods/v3"
    > xmlns:xlink="http://www.w3.org/1999/xlink"
    > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    > xsi:schemaLocation="http://www.loc.gov/mads/ mads.xsd">
    > <authority type="simple"/>
    > </mads>
    >
    > The "type" attribute in element "authority" was automatically added by
    > the parser...
    >
    > But "type" is defined in xlink (namespace
    > "http://www.w3.org/1999/xlink"). Shouldn't
    > Xerces have added its prefix in front?? (xlink:type="simple") ???


    I don't quite understand what you are doing, are you loading an XML
    document from a file to build a DOM (document object model), then
    serialize that DOM back to a file and then the proper namespace
    attribute or prefix is missing?
    Then how exactly do you serialize?




    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Nov 30, 2005
    #2
    1. Advertising

  3. VanOrton

    VanOrton Guest

    Martin, thanks for your quick answer...

    I'm using C++ (Borland C++ Builder).

    Well my XML document is in the form of a text file. The file looks
    exactly like the one
    I posted in my previous post, except that element "authority" has no
    attribute.
    I load the document on a DOM using XercesDOMParser like this:

    DOMXMLparser->setValidationScheme(XercesDOMParser::Val_Auto);
    DOMXMLparser->setDoNamespaces(true);
    DOMXMLparser->setDoSchema(true);
    DOMXMLparser->parse(shortPathName);

    Then I project the DOM tree on a TreeView control and I clearly see
    that Parser
    inserted the "type" attribute by itself.
    The problem is that this node has NULL for prefix (node->getPrefix() =
    NULL).
    It also has: node->getNodeName() = "type" and node->getLocalName() =
    "type".
    It gives: node->getNamespaceURI() = xlink-namespace (the real one!...).

    Shouldn't Xerces have given a name with a prefix to this attribute?
    Or should I do this myself before projecting the DOM to the TreeView?
    And how?... Traverse all document and checking Namespaces and
    Prefices?...

    Am I missing something important maybe?... Thank you very much again...


    Nicolas
    VanOrton, Nov 30, 2005
    #3
    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. Tim Tyler
    Replies:
    36
    Views:
    1,445
    Darryl L. Pierce
    Dec 10, 2004
  2. indo3

    default namespace prefix

    indo3, Jul 13, 2004, in forum: XML
    Replies:
    1
    Views:
    402
    Martin Honnen
    Jul 13, 2004
  3. Robert W.
    Replies:
    2
    Views:
    383
    Robert W.
    Oct 19, 2006
  4. Chris  Chiasson
    Replies:
    6
    Views:
    602
    Richard Tobin
    Nov 14, 2006
  5. RedGrittyBrick
    Replies:
    8
    Views:
    131
Loading...

Share This Page