You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Jason <ja...@yahoo.com> on 2005/02/14 23:38:19 UTC

XML Declaration

Hello,

Consider the following xml snippet:

<?xml version="1.0" encoding="UTF-8" ?> 
<foo TYPE="bar">
</foo>

I have some code which uses a jaxp DocumentBuilder to
parse this xml and then walk to tree and do various
things.  This code works fine with xerces (1.4.x and
2.2.x) but when it's deployed in the Oracle 10g
application server which uses it's own jaxp
implementation there are problems.  It turns out that
the xerces Document resulting from the parse has only
one child which is the 'foo' element while the Oracle
Document has two - the first is the xml declaration
and the second is the 'foo' element.

Obviusly I can code around this easily enough but I'm
wondering which behavior is correct with respect to
the standard or if the standard even applies. 
Possibly the implemenations are free to make whichever
choice they want?  Thanks in advance.

-jason 



		
__________________________________ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: XML Declaration

Posted by Bob Foster <bo...@objfac.com>.
The xml declaration is not a processing instruction. The Oracle parser 
is wrong.

Bob Foster

Jason wrote:
> Hi Alistair,
> 
> I'm not sure why you can't parse the xml.  I've looked
> at this a bit more and it seems that the Oracle parser
> is reporting the xml delcaration as a Processing
> Instruction.  It never occurred to me but I guess that
> the xml declaration does follow the PI format.  So, I
> guess the question is, is it a PI or isn't it?
> 
> -jason
> 
> --- Alistair Young <al...@smo.uhi.ac.uk> wrote:
> 
> 
>>><?xml version="1.0" encoding="UTF-8" ?>
>>
>>using xerces through JAXP, if this line is present,
>>I get a SAXException
>>every time when parsing the doc, along the lines of
>>xml element not
>>allowed here. I have to remove the line before the
>>doc will parse.
>>Am I missing something?
>>
>>thanks,
>>Alistair
>>
>>
>>-- 
>>Alistair Young
>>Senior Software Engineer
>>UHI@Sabhal Mòr Ostaig
>>Isle of Skye
>>Scotland
>>
>>
>>>Hello,
>>>
>>>Consider the following xml snippet:
>>>
>>><?xml version="1.0" encoding="UTF-8" ?>
>>><foo TYPE="bar">
>>></foo>
>>>
>>>I have some code which uses a jaxp DocumentBuilder
>>
>>to
>>
>>>parse this xml and then walk to tree and do
>>
>>various
>>
>>>things.  This code works fine with xerces (1.4.x
>>
>>and
>>
>>>2.2.x) but when it's deployed in the Oracle 10g
>>>application server which uses it's own jaxp
>>>implementation there are problems.  It turns out
>>
>>that
>>
>>>the xerces Document resulting from the parse has
>>
>>only
>>
>>>one child which is the 'foo' element while the
>>
>>Oracle
>>
>>>Document has two - the first is the xml
>>
>>declaration
>>
>>>and the second is the 'foo' element.
>>>
>>>Obviusly I can code around this easily enough but
>>
>>I'm
>>
>>>wondering which behavior is correct with respect
>>
>>to
>>
>>>the standard or if the standard even applies.
>>>Possibly the implemenations are free to make
>>
>>whichever
>>
>>>choice they want?  Thanks in advance.
>>>
>>>-jason
>>>
>>>
>>>
>>>
>>>__________________________________
>>>Do you Yahoo!?
>>>Read only the mail you want - Yahoo! Mail
>>
>>SpamGuard.
>>
>>>http://promotions.yahoo.com/new_mail
>>>
>>>
>>
> ---------------------------------------------------------------------
> 
>>>To unsubscribe, e-mail:
>>
>>xerces-j-user-unsubscribe@xml.apache.org
>>
>>>For additional commands, e-mail:
>>
>>xerces-j-user-help@xml.apache.org
>>
>>>
>>
>>
> ---------------------------------------------------------------------
> 
>>To unsubscribe, e-mail:
>>xerces-j-user-unsubscribe@xml.apache.org
>>For additional commands, e-mail:
>>xerces-j-user-help@xml.apache.org
>>
>>
> 
> 
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> Yahoo! Mail - Find what you need with new enhanced search.
> http://info.mail.yahoo.com/mail_250
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> 
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: XML Declaration

Posted by Jason <ja...@yahoo.com>.
Hi Alistair,

I'm not sure why you can't parse the xml.  I've looked
at this a bit more and it seems that the Oracle parser
is reporting the xml delcaration as a Processing
Instruction.  It never occurred to me but I guess that
the xml declaration does follow the PI format.  So, I
guess the question is, is it a PI or isn't it?

-jason

--- Alistair Young <al...@smo.uhi.ac.uk> wrote:

> > <?xml version="1.0" encoding="UTF-8" ?>
> using xerces through JAXP, if this line is present,
> I get a SAXException
> every time when parsing the doc, along the lines of
> xml element not
> allowed here. I have to remove the line before the
> doc will parse.
> Am I missing something?
> 
> thanks,
> Alistair
> 
> 
> -- 
> Alistair Young
> Senior Software Engineer
> UHI@Sabhal M�r Ostaig
> Isle of Skye
> Scotland
> 
> > Hello,
> >
> > Consider the following xml snippet:
> >
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <foo TYPE="bar">
> > </foo>
> >
> > I have some code which uses a jaxp DocumentBuilder
> to
> > parse this xml and then walk to tree and do
> various
> > things.  This code works fine with xerces (1.4.x
> and
> > 2.2.x) but when it's deployed in the Oracle 10g
> > application server which uses it's own jaxp
> > implementation there are problems.  It turns out
> that
> > the xerces Document resulting from the parse has
> only
> > one child which is the 'foo' element while the
> Oracle
> > Document has two - the first is the xml
> declaration
> > and the second is the 'foo' element.
> >
> > Obviusly I can code around this easily enough but
> I'm
> > wondering which behavior is correct with respect
> to
> > the standard or if the standard even applies.
> > Possibly the implemenations are free to make
> whichever
> > choice they want?  Thanks in advance.
> >
> > -jason
> >
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Read only the mail you want - Yahoo! Mail
> SpamGuard.
> > http://promotions.yahoo.com/new_mail
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail:
> xerces-j-user-help@xml.apache.org
> >
> >
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> xerces-j-user-help@xml.apache.org
> 
> 



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: XML Declaration

Posted by Alistair Young <al...@smo.uhi.ac.uk>.
thanks all for your replies. I was getting the error:

"The processing instruction target matching "[xX][mM][lL]" is not 
allowed."

I had a comment as the first line in the file. Removing it fixed the 
problem.

many thanks,
Alistair

On 14 Feb 2005, at 22:58, Joseph Kesselman wrote:

>
>
>
>
> The XML Declaration must start at the very first character of the XML
> document being parsed -- if you have a blank line or space in front of 
> it,
> fix that. (The one exception is that a two-byte Byte Order Mark may 
> preceed
> the XML Declaration.)
>
> ______________________________________
> Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
> "The world changed profoundly and unpredictably the day Tim Berners Lee
> got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: XML Declaration

Posted by Joseph Kesselman <ke...@us.ibm.com>.



The XML Declaration must start at the very first character of the XML
document being parsed -- if you have a blank line or space in front of it,
fix that. (The one exception is that a two-byte Byte Order Mark may preceed
the XML Declaration.)

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: XML Declaration

Posted by Alistair Young <al...@smo.uhi.ac.uk>.
> <?xml version="1.0" encoding="UTF-8" ?>
using xerces through JAXP, if this line is present, I get a SAXException
every time when parsing the doc, along the lines of xml element not
allowed here. I have to remove the line before the doc will parse.
Am I missing something?

thanks,
Alistair


-- 
Alistair Young
Senior Software Engineer
UHI@Sabhal Mòr Ostaig
Isle of Skye
Scotland

> Hello,
>
> Consider the following xml snippet:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <foo TYPE="bar">
> </foo>
>
> I have some code which uses a jaxp DocumentBuilder to
> parse this xml and then walk to tree and do various
> things.  This code works fine with xerces (1.4.x and
> 2.2.x) but when it's deployed in the Oracle 10g
> application server which uses it's own jaxp
> implementation there are problems.  It turns out that
> the xerces Document resulting from the parse has only
> one child which is the 'foo' element while the Oracle
> Document has two - the first is the xml declaration
> and the second is the 'foo' element.
>
> Obviusly I can code around this easily enough but I'm
> wondering which behavior is correct with respect to
> the standard or if the standard even applies.
> Possibly the implemenations are free to make whichever
> choice they want?  Thanks in advance.
>
> -jason
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Read only the mail you want - Yahoo! Mail SpamGuard.
> http://promotions.yahoo.com/new_mail
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: XML Declaration

Posted by Jason <ja...@yahoo.com>.
Thanks Joe, for the clarification.  I've found that I
can side step the issue altogether if I call
getDocumentElement( ) rather than getChild( ).

-jason
--- Joseph Kesselman <ke...@us.ibm.com> wrote:

> 
> 
> 
> 
> Oracle is wrong. The XML Declaration is not a child
> in the DOM. Complain to
> them and see if they offer a mode which handles it
> properly.
> 
> (The DOM had no standard API for the XML Declaration
> until DOM Level 3,
> which is part of why some parsers tried to cheat by
> turning it into a
> special node or -- erroneously -- calling it a
> Processing Instruction. But
> the DOM WG has said repeatedly that this kluge was,
> in fact, incorrect.)
> 
> ______________________________________
> Joe Kesselman, IBM Next-Generation Web Technologies:
> XML, XSL and more.
> "The world changed profoundly and unpredictably the
> day Tim Berners Lee
> got bitten by a radioactive spider." -- Rafe Culpin,
> in r.m.filk
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> xerces-j-user-help@xml.apache.org
> 
> 



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: XML Declaration

Posted by Joseph Kesselman <ke...@us.ibm.com>.



Oracle is wrong. The XML Declaration is not a child in the DOM. Complain to
them and see if they offer a mode which handles it properly.

(The DOM had no standard API for the XML Declaration until DOM Level 3,
which is part of why some parsers tried to cheat by turning it into a
special node or -- erroneously -- calling it a Processing Instruction. But
the DOM WG has said repeatedly that this kluge was, in fact, incorrect.)

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org