[Rd] xmlParseDoc parser errors

bryan rasmussen rasmussen.bryan at gmail.com
Fri Nov 16 15:10:07 CET 2012


Hi,

I have some XML files that have a processing instruction directly
after the XML declaration

when I do
kgroup.reading <- character(0)
for (file in file_list){kgroup.reading <-
xmlParseDoc(file.path("c:","projects","respositories","dk","004",file))}

I get the error
file name :1: parser error : Start tag expected, '<' not found

When I remove the processing instruction and try to load it again I do
not get the parser error.

This is of course understandable because of

 [Definition: Processing instructions (PIs) allow documents to contain
instructions for applications.]
Processing Instructions
[16]   	PI	   ::=   	'<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
[17]   	PITarget	   ::=   	Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))

PIs are not part of the document's character data, but MUST be passed
through to the application. The PI begins with a target (PITarget)
used to identify the application to which the instruction is directed.
The target names " XML ", " xml ", and so on are reserved for
standardization in this or future versions of this specification. The
XML Notation mechanism may be used for formal declaration of PI
targets. Parameter entity references MUST NOT be recognized within
processing instructions.

from the specification, on the other hand it does not say that it is
never allowed for any PI given that they (the W3C) are planning to use
it for  'standardization in this or future versions of this
specification'

Unfortunately the people who made the xml-model processing instruction

http://www.w3.org/TR/2012/NOTE-xml-model-20121009/#the-xml-model-processing-instruction

I guess decided they had the right to standardize a processing
instruction name.

Is there any way to get around this problem?

Also When I do the following:

 t <- '<?xml version="1.0" encoding="utf-8"?><?xml-model
href="urn:publicid:-:Thomson+Information+AS:DTD+AFGRDOK:DK"?><t></t>'
> xmlParseDoc(t)
I get the parser warning

<?xml version="1.0" encoding="utf-8"?><?xml-model
href="urn:publicid:-:Thomson+Information+AS:DTD+AFGRDOK:DK"?><t></t>:1:
parser warning : xmlParsePITarget: invalid name prefix 'xml'
<?xml version="1.0" encoding="utf-8"?><?xml-model href="urn:publicid:-:Thomson+I

Why do I get it as a parser error when I load the document, but a
parser warning when I load it as a string?
Anyway just to get it as a warning when I load the document?

Thanks,
Bryan Rasmussen



More information about the R-devel mailing list