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 Robert van Loenhout <r....@greenvalley.nl> on 2004/06/02 17:45:19 UTC

Parsing processing instructions

Hi,

Is there some easy way with Xerces to parse the attributes of processing
instructions in XML?
I tried using the getAttributes method of the ProcessingInstruction, but
this return null just
like it says in the documentation:
"A NamedNodeMap containing the attributes of this node (if it is an Element)
or null otherwise."

I could parse it manually, but I find it strange that I would have to do
this since I am already using a parser and the attributes of a processing
instruction seems the same to me as any element.




                                                                              
                                                                              
                                                                               
                                                                            

                
                                                                 

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


Re: Parsing processing instructions

Posted by Robert van Loenhout <r....@greenvalley.nl>.
Joseph Kesselman wrote:
> > It's not without reason that the XML specification calls them
> > "pseudo-attributes". The content of a PI can be anything,
>
> Specific citation: http://www.w3.org/TR/2004/REC-xml11-20040204/#sec-pi
>
> A PI's contents are its target name, and a block of arbitrary characters,
> separated by whitespace.  The interpretation of that character data is up
> to whoever defined the PI. It may look like attributes... or it may look
> like anything else which that PI considers meaningful. The only rule is
> that the value can't contain the ?> sequence which ends the PI.

Okay, that makes sense why Xerces does not parse the PI's.
Although I don't think it was the right choice of w3c to allow any content
in the PI.

So with some regular expression I managed to do a name/value parsing that is
enough for now.

Thanks for the information.


                                                                              
                                                                              
                                                                               
                                                                            

                
                                                                 

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


Re: Parsing processing instructions

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



>It's not without reason that the XML specification calls them
>"pseudo-attributes". The content of a PI can be anything,

Specific citation: http://www.w3.org/TR/2004/REC-xml11-20040204/#sec-pi

A PI's contents are its target name, and a block of arbitrary characters,
separated by whitespace.  The interpretation of that character data is up
to whoever defined the PI. It may look like attributes... or it may look
like anything else which that PI considers meaningful. The only rule is
that the value can't contain the ?> sequence which ends the PI.

Yeah, it might be nice if XML APIs provided a convenience function to parse
pseudo-attributes out of an arbitrary string, since that syntax does get
reused in PIs and elsewhere. At the moment they don't.

______________________________________
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: Parsing processing instructions

Posted by Sebastian Redl <wa...@gmx.net>.
Robert van Loenhout wrote:

>Hi,
>
>I could parse it manually, but I find it strange that I would have to do
>this since I am already using a parser and the attributes of a processing
>instruction seems the same to me as any element.
>
>  
>
It's not without reason that the XML specification calls them 
"pseudo-attributes". The content of a PI can be anything, and if that 
anything takes the form of attributes then this is conincidence. It's up 
to the user of the PI to parse its contents.

Sebastian Redl

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