Reputation: 8497
I want to break the xmlns declarations into multiple lines. I've seen it in text books, but when I try to replicate it, [shell-tools][1] gives an error for the second example below:
/var/tmp/FOO758cqr:11: parser error : Premature end of data in tag book line 2
How do I change this:
<?xml version="1.0"?>
<!-- initially, the default namespace is "books" -->
<book xmlns="urn:loc.gov:books" xmlns:isbn="urn:ISBN:0-395-36341-6">
<title>Cheaper by the Dozen</title>
<isbn:number>1568491379</isbn:number>
<notes>
<!-- make HTML the default namespace for some commentary -->
<p xmlns="http://www.w3.org/1999/xhtml">
This is a <i>funny</i> book!
</p>
</notes>
</book>
to this:
<?xml version="1.0"?>
<book xmlns="urn:loc.gov:books">
<book xmlns:isbn="urn:ISBN:0-395-36341-6">
<title>Cheaper by the Dozen</title>
<isbn:number>1568491379</isbn:number>
<notes>
<p>
This is a <i>funny</i> book!
</p>
</notes>
</book>
(above is from scoping@w3)
I'd like to make the scope for both namespaces to be all of books, if that makes sense.
thanks,
Thufir
(reading [codenotes][3] pg 35)
Upvotes: 2
Views: 219
Reputation: 272397
You want:
<book
xmlns="urn:loc.gov:books"
xmlns:isbn="urn:ISBN:0-395-36341-6">
keeping the attributes within the single <book>
node. Note that you can't have two root nodes, so two <book>
nodes is not going to be acceptable in the above example.
Upvotes: 2
Reputation: 9068
The second example is not well-formed XML (one of the <book>
tags is not closed), that's why the error occurs.
What you might want is:
<?xml version="1.0"?>
<!-- initially, the default namespace is "books" -->
<book xmlns="urn:loc.gov:books"
xmlns:isbn="urn:ISBN:0-395-36341-6">
<title>Cheaper by the Dozen</title>
<isbn:number>1568491379</isbn:number>
<notes>
<!-- make HTML the default namespace for some commentary -->
<p xmlns="http://www.w3.org/1999/xhtml">
This is a <i>funny</i> book!
</p>
</notes>
</book>
Upvotes: 2