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 Varadharajan Sethuraman <va...@yahoo.com> on 2004/02/26 08:34:57 UTC

Read Processing Instruction

Hi,

I have one sample XML as below:

<?xml version="1.0"?>
<samples>
<server>UNIX</server>
<monitor>color</monitor>
</samples>

Now I want to extract the value from XML Declaration
(<?xml version="1.0"?>)  in the XML file

Can u advice me?

Regards
Varadharajan S




__________________________________
Do you Yahoo!?
Get better spam protection with Yahoo! Mail.
http://antispam.yahoo.com/tools

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


Re: Read Processing Instruction

Posted by Andy Clark <an...@apache.org>.
Varadharajan Sethuraman wrote:
> Now I want to extract the value from XML Declaration
> (<?xml version="1.0"?>)  in the XML file

You can't access this information from DOM or SAX. But
XNI provides it. Extend the Xerces parser of your choice
(e.g. org.apache.xerces.parsers.DOMParser) and override
the xmlDecl method.

-- 
Andy Clark * andyc@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: Read Processing Instruction

Posted by Michael Glavassevich <mr...@apache.org>.
SAX2 1.1 Extensions has an interface called Locator2 [1] which extends
Locator providing methods for accessing the xml version and encoding of
entities. There's also a feature called 'is-standalone' which exposes
whether the document has been declared to be standalone. These extensions
currently have beta status but based on the revitalized discussion on
SAX for JAXP 1.3 they may be finalized fairly soon.

[1] http://www.saxproject.org/?selected=ext

On Thu, 26 Feb 2004, Joseph Kesselman wrote:

> The XML Declaration is officially not considered a processing instruction,
> and can't be treated as one.
>
> DOM Level 3 is planning to add calls to retrieve information from the XML
> Declaration (xmEncoding,  xmlStandalone, xmlVersion, inputEncoding), Xerces
> probably has a beta/prototype of that functionality; I haven't checked
> recently. DOM3 Core is a PR right now; I'm not sure when it might become a
> REC. Of course this wouldn't be portable to systems that don't implement
> DOM3, but it should be more portable than the XNI alternative.
>
> I don't know what plans, if any, exist to update the SAX standard.
>
> ______________________________________
> 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

---------------------------
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@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: Read Processing Instruction

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



The XML Declaration is officially not considered a processing instruction,
and can't be treated as one.

DOM Level 3 is planning to add calls to retrieve information from the XML
Declaration (xmEncoding,  xmlStandalone, xmlVersion, inputEncoding), Xerces
probably has a beta/prototype of that functionality; I haven't checked
recently. DOM3 Core is a PR right now; I'm not sure when it might become a
REC. Of course this wouldn't be portable to systems that don't implement
DOM3, but it should be more portable than the XNI alternative.

I don't know what plans, if any, exist to update the SAX standard.

______________________________________
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