Rev 7747 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
# cat(paste(names(parserOptions), paste(2, 0:(length(parserOptions) - 1), sep = "^"), sep = " = ", collapse = "\n"))#setClass("XMLParserOption", "EnumValue")parserOptions =structure(c(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048,4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576), .Names = c("RECOVER", "NOENT", "DTDLOAD", "DTDATTR", "DTDVALID","NOERROR", "NOWARNING", "PEDANTIC", "NOBLANKS", "SAX1", "XINCLUDE","NONET", "NODICT", "NSCLEAN", "NOCDATA", "NOXINCNODE", "COMPACT","OLD10", "NOBASEFIX", "HUGE", "OLDSAX"))RECOVER = 2^0NOENT = 2^1DTDLOAD = 2^2DTDATTR = 2^3DTDVALID = 2^4NOERROR = 2^5NOWARNING = 2^6PEDANTIC = 2^7NOBLANKS = 2^8SAX1 = 2^9XINCLUDE = 2^10NONET = 2^11NODICT = 2^12NSCLEAN = 2^13NOCDATA = 2^14NOXINCNODE = 2^15COMPACT = 2^16OLD10 = 2^17NOBASEFIX = 2^18HUGE = 2^19OLDSAX = 2^20## This can (and does) send illegal file names to file.exists(), which## has been protected against that but should really be caught here.xmlParseDoc =function(file, options = 1L, encoding = character(), asText = !file.exists(file),baseURL = file){if(is.character(options)) {i = pmatch(options, names(parserOptions))if(any(is.na(i)))stop("unrecognized XML parser options: ", paste(options[is.na(i)], collapse = ", "))options = parserOptions[i]} else {if(!all(options %in% parserOptions))stop("unrecognized XML parser options: ", paste(options[!(options %in% parserOptions)], collapse = ", "))}options = as.integer(sum(options))if(asText).Call("R_xmlReadMemory", file, nchar(file), as.character(encoding), options, as.character(baseURL), PACKAGE = "XML")else.Call("R_xmlReadFile", path.expand(file), as.character(encoding), options, PACKAGE = "XML")}