Fragment parsing

P

Philippe Poulard

hi,

i have the following fragment :
******
<?xml version="1.0">
Begin
<elem/>
End

******
i intend to insert it within this document :
******
<?xml version="1.0">
<!DOCTYPE root [
<!ENTITY in SYSTEM "fragment.xml">
]>
<root>
Hello world !!!&in;
</root>

******
the result is (after serialization) :
******
<?xml version="1.0">
<root>
Hello world !!!
Begin
<elem/>
End

</root>
******
while i was expecting :
******
<?xml version="1.0">
<root>
Hello world !!!Begin
<elem/>
End

</root>
******
i thought that the text declaration should behave like the xml
declaration, that is to say that "<?xml ...?>CR" was entirely discarded
(including the CR) before replacement

do i have to remove the first CR at hand ?

do i have to correct my fragment :
******
<?xml version="1.0"?>Begin
<elem/>
End

****** ?

did i miss something ???

--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
 
R

Richard Tobin

i thought that the text declaration should behave like the xml
declaration, that is to say that "<?xml ...?>CR" was entirely discarded
(including the CR) before replacement

No, the line break after the text declaration is not part of the
declaration so it is part of the replacement text of the entity.

The same is true of the XML declaration; the only reason you don't
see the line break after that is that it's outside the document
element.
do i have to remove the first CR at hand ?
Yes.

do i have to correct my fragment :
******
<?xml version="1.0"?>Begin
<elem/>
End

****** ?

The text declaration must contain an encoding declaration. And you
don't have to have a text declaration at all unless you want to
specify an encoding or a version > 1.0.

-- Richard
 

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

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top