xinclude- need for namespace

Discussion in 'XML' started by chuck, Nov 23, 2011.

  1. chuck

    chuck Guest

    Hi,
    When using xinclude to incorporate other XML documents in mine why do I need a namespace to qualify the "include" statement?

    Is it the case that the parser will act on only those include statements that are qualified by this namespace?

    Just curious, that's all

    Thanks!
     
    chuck, Nov 23, 2011
    #1
    1. Advertising

  2. * chuck wrote in comp.text.xml:
    >When using xinclude to incorporate other XML documents in mine why do I
    >need a namespace to qualify the "include" statement?
    >
    >Is it the case that the parser will act on only those include statements
    >that are qualified by this namespace?


    You might also want other applications to ignore the include statement,
    say you might want your schema-driven editor to not complain about the
    element, but yes, identification is the motivation behind having it in
    one particular namespace. Also consider that a future XInclude version
    might want to change some behavior without changing the syntax too much,
    and <include xmlns='...' ... /> looks better than <include2.0 ... />.
    --
    Björn Höhrmann · mailto: · http://bjoern.hoehrmann.de
    Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
    25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
     
    Bjoern Hoehrmann, Nov 24, 2011
    #2
    1. Advertising

  3. On 11/23/2011 6:59 PM, chuck wrote:
    > Hi, When using xinclude to incorporate other XML documents in mine
    > why do I need a namespace to qualify the "include" statement?


    Namespaces are part of the name of the element or attribute, and serve
    to help prevent collision between similar names being used for different
    purposes. <include>, without a namespace or with the wrong namespace, is
    not an XInclude directive.

    Of course you could implement the equivalent of XInclude behavior in
    your own language, and call it whatever you want... but then you would
    have to provide your own implementation rather than being able to take
    advantage of an existing XInclude processing layer.

    --
    Joe Kesselman,
    http://www.love-song-productions.com/people/keshlam/index.html

    {} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
    /\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
     
    Joe Kesselman, Nov 24, 2011
    #3
  4. One way to think about this is that
    <foo xmlns="http://keshlam.name/mynamespace"/>
    or
    <myns:foo xmlns:myns="http://keshlam.name/mynamespace"/>
    is sorta-almost a shorthand for
    < {http://keshlam.name/mynamespace}foo />
    That brace-delimited version is not actually supported by XML, but it
    illustrates the intent: the namespace URI is considered to be part of
    the name of the element, and the prefix or default-namespace syntax is
    used instead because that's easier for humans to read and (usually) more
    compact.


    --
    Joe Kesselman,
    http://www.love-song-productions.com/people/keshlam/index.html

    {} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
    /\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
     
    Joe Kesselman, Nov 24, 2011
    #4
  5. chuck

    chuck Guest

    Thanks Joe and Bjoern for a good explanation. As you say, it's possible there could be another "include" that comes along which need not be for including an external file

    I have a follow-up question.
    As you must have surmised I'm kind of learning here. Once I have done the xinclude how do I get to see the xml document with the included files expanded? I come from an IBM mainframe b/g and xinclude is somewhat similar to a COBOL Copy verb. oVer there when I compile the program the Copied file isexpanded.

    How does that work here?

    Thanks!
     
    chuck, Nov 24, 2011
    #5
  6. * chuck wrote in comp.text.xml:
    >As you must have surmised I'm kind of learning here. Once I have done
    >the xinclude how do I get to see the xml document with the included
    >files expanded? I come from an IBM mainframe b/g and xinclude is
    >somewhat similar to a COBOL Copy verb. oVer there when I compile the
    >program the Copied file is expanded.


    You would have to run it through an XInclude processor which does that.
    The xmllint program that comes with libxml2 http://xmlsoft.org/ can do
    this, `xmllint --xinclude example.xml` would print the result.
    --
    Björn Höhrmann · mailto: · http://bjoern.hoehrmann.de
    Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
    25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
     
    Bjoern Hoehrmann, Nov 25, 2011
    #6
  7. chuck

    chuck Guest

    Thank you, sir. It worked. I ran into problems making it work on Windows, it kept complaining of 1 missing DLL after another.
    I happen to have a box running Ubuntu and it worked fine over there.
     
    chuck, Nov 25, 2011
    #7
    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. Ed Dennison
    Replies:
    0
    Views:
    464
    Ed Dennison
    Sep 12, 2003
  2. CB
    Replies:
    1
    Views:
    549
    Igor Zlatkovic
    Aug 25, 2004
  3. SL
    Replies:
    0
    Views:
    525
  4. Larry
    Replies:
    1
    Views:
    1,353
    Richard Tobin
    Sep 20, 2005
  5. pxpilot
    Replies:
    1
    Views:
    388
    Pavel Lepin
    Oct 16, 2007
Loading...

Share This Page