No way to use entities in a document using schema?

Discussion in 'XML' started by Kent Tong, Feb 19, 2004.

  1. Kent Tong

    Kent Tong Guest

    Hi,

    This is wha I'm trying to do:

    <?xml version="1.0"?>
    <!DOCTYPE library [
    <!ENTITY foo "Some sentence...">
    ]>
    <library xmlns="http://foo.com">
    &foo;
    </library>

    But Xerces is saying that "library" element type is undefined. I can
    understand that as library is defined in the "http://foo.com"
    namespace. Does it means that it is impossible to use entities in
    a document using schema/namespace?

    If it is true, then it is impossible to split a large xml file into
    several small files and then include them as external entites?

    Thanks for any advice!
     
    Kent Tong, Feb 19, 2004
    #1
    1. Advertising

  2. (Kent Tong) wrote in message news:<>...
    > Hi,
    >
    > This is wha I'm trying to do:
    >
    > <?xml version="1.0"?>
    > <!DOCTYPE library [
    > <!ENTITY foo "Some sentence...">
    > ]>
    > <library xmlns="http://foo.com">
    > &foo;
    > </library>
    >
    > But Xerces is saying that "library" element type is undefined. I can
    > understand that as library is defined in the "http://foo.com"
    > namespace. Does it means that it is impossible to use entities in
    > a document using schema/namespace?
    >
    > If it is true, then it is impossible to split a large xml file into
    > several small files and then include them as external entites?
    >
    > Thanks for any advice!


    If I understand well, you don't want to do validation here at all.
    Just suppress validation -- the parser will still read the DTD and
    will correctly substitute the value of the entity for every occurence
    of its entity reference.


    Cheers,

    Cheers,

    Dimitre Novatchev [XML MVP],
    FXSL developer, XML Insider,

    http://fxsl.sourceforge.net/ -- the home of FXSL
    Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
     
    Dimitre Novatchev, Feb 19, 2004
    #2
    1. Advertising

  3. Kent Tong

    Kent Tong Guest

    (Dimitre Novatchev) wrote in message news:<>...
    > (Kent Tong) wrote in message news:<>...
    > If I understand well, you don't want to do validation here at all.
    > Just suppress validation -- the parser will still read the DTD and
    > will correctly substitute the value of the entity for every occurence
    > of its entity reference.


    No, I am not trying to surpress validation. I want validation.

    What I am trying to do is:
    1. to introduce an entity to represent a long sentence that
    would be used in many places.
    2. to let different people work on different XML files and
    then include the files into the main XML file.
     
    Kent Tong, Feb 20, 2004
    #3
  4. (Kent Tong) wrote in message news:<>...
    > (Dimitre Novatchev) wrote in message news:<>...
    > > (Kent Tong) wrote in message news:<>...
    > > If I understand well, you don't want to do validation here at all.
    > > Just suppress validation -- the parser will still read the DTD and
    > > will correctly substitute the value of the entity for every occurence
    > > of its entity reference.

    >
    > No, I am not trying to surpress validation. I want validation.
    >
    > What I am trying to do is:
    > 1. to introduce an entity to represent a long sentence that
    > would be used in many places.
    > 2. to let different people work on different XML files and
    > then include the files into the main XML file.


    Then you have to write the DTD to describe the structure of this
    document type and the real names of the elements.

    Unfortunately, DTD's are not namespace aware, therefore namespaces are
    defined as attributes.

    Here's the correct DTD for your document:

    <!DOCTYPE library [
    <!ENTITY foo "Some sentence...">
    <!ELEMENT library (#PCDATA)>
    <!ATTLIST library xmlns CDATA #FIXED
    "http://foo.com" >

    ]>
    <library xmlns="http://foo.com">
    &foo;
    </library>

    You can check that now the validation is successful.

    I'd greatly recommend a good book on XML -- the one that I have
    recently read is:

    "Effective XML, 50 Specific Ways to Improve Your XML", by Elliotte
    Rusty Harold.

    This is a great book that goes deep into many advanced topics of XML.


    Hope this helped.


    Cheers,

    Dimitre Novatchev [XML MVP],
    FXSL developer, XML Insider,

    http://fxsl.sourceforge.net/ -- the home of FXSL
    Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
     
    Dimitre Novatchev, Feb 20, 2004
    #4
    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. Markus
    Replies:
    1
    Views:
    1,641
    Markus
    Nov 23, 2005
  2. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,314
    Stanimir Stamenkov
    Apr 25, 2005
  3. Robert Oschler
    Replies:
    8
    Views:
    768
    Christopher T King
    Jul 31, 2004
  4. Robert Brewer
    Replies:
    0
    Views:
    528
    Robert Brewer
    Jul 25, 2004
  5. Jim Higson
    Replies:
    3
    Views:
    241
    Eric Amick
    Jul 25, 2004
Loading...

Share This Page