Should Xpath select nodes containing default values??

Discussion in 'XML' started by aman.coe@gmail.com, Oct 21, 2005.

  1. Guest

    hello all

    Consider this xml file:

    <root>
    <body>
    <ElementX id="X1" Xproperty="X_Default_Value" />
    <ElementX id="X2" />
    </body>
    </root>

    Here for the element of type 'ElementX' the attribute 'Xproperty' has
    default value as 'X_Default_Value'.

    Now the question is whether the following Xpath Expression
    "//ElementX[@Xproperty='X_Default_Value']" would select a single node
    ie ElementX with id as 'X1' or 2 ElementX nodes.

    Thanx in advance.
    , Oct 21, 2005
    #1
    1. Advertising

  2. wrote:


    > <root>
    > <body>
    > <ElementX id="X1" Xproperty="X_Default_Value" />
    > <ElementX id="X2" />
    > </body>
    > </root>
    >
    > Here for the element of type 'ElementX' the attribute 'Xproperty' has
    > default value as 'X_Default_Value'.


    Where is the DOCTYPE declaration then?

    > Now the question is whether the following Xpath Expression
    > "//ElementX[@Xproperty='X_Default_Value']" would select a single node
    > ie ElementX with id as 'X1' or 2 ElementX nodes.


    It will depend on the parser or implemention settings whether it reads a
    DTD or schema and adds default values defined there. If those are added
    then the XPath expression will select two element nodes.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Oct 21, 2005
    #2
    1. Advertising

  3. Guest

    Thanks for your time.

    Aman

    Martin Honnen wrote:
    > wrote:
    >
    >
    > > <root>
    > > <body>
    > > <ElementX id="X1" Xproperty="X_Default_Value" />
    > > <ElementX id="X2" />
    > > </body>
    > > </root>
    > >
    > > Here for the element of type 'ElementX' the attribute 'Xproperty' has
    > > default value as 'X_Default_Value'.

    >
    > Where is the DOCTYPE declaration then?
    >
    > > Now the question is whether the following Xpath Expression
    > > "//ElementX[@Xproperty='X_Default_Value']" would select a single node
    > > ie ElementX with id as 'X1' or 2 ElementX nodes.

    >
    > It will depend on the parser or implemention settings whether it reads a
    > DTD or schema and adds default values defined there. If those are added
    > then the XPath expression will select two element nodes.
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/
    , Oct 22, 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. Hannes Heckner
    Replies:
    1
    Views:
    764
    Martin Honnen
    Oct 13, 2003
  2. Kevin
    Replies:
    3
    Views:
    1,577
    Martin Honnen
    Jan 30, 2004
  3. eggie5
    Replies:
    1
    Views:
    530
    Joseph Kesselman
    Oct 2, 2007
  4. Marek
    Replies:
    1
    Views:
    1,592
    Marek
    Jun 24, 2008
  5. wvxvw
    Replies:
    0
    Views:
    2,677
    wvxvw
    Sep 26, 2009
Loading...

Share This Page