Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] XInclusion produdes invalid document

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Harold <elharo AT metalab.unc.edu>
  • To: Andrew Thompson <lordpixel AT mac.com>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] XInclusion produdes invalid document
  • Date: Sun, 06 Mar 2005 17:19:19 -0500

Andrew Thompson wrote:


So I boiled this down to a test case:

Here's the include file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";
xmlns:xi="http://www.w3.org/2001/XInclude";
xml:lang="en" lang="en">
<head>
<title>Hello world</title>
</head>
<body>
<p>foo</p>
<xi:include href="navbar.xml"/>
</body>
</html>

Here's what it includes (navbar.xml):

<p id="navbar" class="">
<a href="/index.php" title="My Homepage">Home</a> |
<a href="/code/index.php" title="Code I've written">Code</a> |
<a href="/photos/index.php" title="Pictures of people I know and places I've been">Photos</a> |
<a href="http://www.mozilla.org/";>Mozilla</a> |
<a href="http://diary.recoil.org/pixel/";>Diary</a></p>

If that's not enough context I can always zip everything up at this end and send it to you.


That's enough. It's your bug and it's easy to fix. You are including a document that does not use namespaces into a document that does. Therefore XInclusion adds an xmlns="" attribute to preserve the correct namespace URIs in the navbar.xml.

Remember: XInclude is not just copy and paste.

The fix is to add the XHTML namespace to navbar.xml.


<p id="navbar" class="" xmlns="http://www.w3.org/1999/xhtml";>

--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim




Archive powered by MHonArc 2.6.24.

Top of Page