Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

xinclude- need for namespace

14 views
Skip to first unread message

chuck

unread,
Nov 23, 2011, 6:59:10 PM11/23/11
to
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!

Bjoern Hoehrmann

unread,
Nov 23, 2011, 7:44:31 PM11/23/11
to
* 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:bjo...@hoehrmann.de · 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/

Joe Kesselman

unread,
Nov 24, 2011, 12:59:26 AM11/24/11
to
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

unread,
Nov 24, 2011, 2:33:14 AM11/24/11
to
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.

chuck

unread,
Nov 24, 2011, 6:56:00 PM11/24/11
to
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 is expanded.

How does that work here?

Thanks!

Bjoern Hoehrmann

unread,
Nov 24, 2011, 9:33:32 PM11/24/11
to
* 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.

chuck

unread,
Nov 25, 2011, 2:46:43 PM11/25/11
to derh...@gmx.net
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.

0 new messages