xinclude- need for namespace

C

chuck

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!
 
B

Bjoern Hoehrmann

* 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 ... />.
 
J

Joe Kesselman

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."
 
J

Joe Kesselman

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."
 
C

chuck

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!
 
B

Bjoern Hoehrmann

* 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.
 
C

chuck

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top