Skip to content

Commit

Permalink
Use ParserOption constants declared in gokogiri
Browse files Browse the repository at this point in the history
  • Loading branch information
jbowtie committed Nov 20, 2013
1 parent 766b79c commit 0d5d883
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 29 deletions.
2 changes: 1 addition & 1 deletion ratago.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func xmlReadFile(filename string) (doc *xml.XmlDocument, err error) {
if err != nil {
return
}
doc, err = xml.Parse(data, xml.DefaultEncodingBytes, nil, xslt.XSLT_PARSE_OPTIONS, xml.DefaultEncodingBytes)
doc, err = xml.Parse(data, xml.DefaultEncodingBytes, nil, xml.StrictParseOption, xml.DefaultEncodingBytes)
return
}

Expand Down
29 changes: 1 addition & 28 deletions xslt/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,11 @@ import (
"io/ioutil"
)

/*
XML_PARSE_RECOVER = 1 // recover on errors
XML_PARSE_NOENT = 2 // substitute entities
XML_PARSE_DTDLOAD = 4 // load the external subset
XML_PARSE_DTDATTR = 8 // default DTD attributes
XML_PARSE_DTDVALID = 16 // validate with the DTD
XML_PARSE_NOERROR = 32 // suppress error reports
XML_PARSE_NOWARNING = 64 // suppress warning reports
XML_PARSE_PEDANTIC = 128 // pedantic error reporting
XML_PARSE_NOBLANKS = 256 // remove blank nodes
XML_PARSE_SAX1 = 512 // use the SAX1 interface internally
XML_PARSE_XINCLUDE = 1024 // Implement XInclude substitition
XML_PARSE_NONET = 2048 // Forbid network access
XML_PARSE_NODICT = 4096 // Do not reuse the context dictionnary
XML_PARSE_NSCLEAN = 8192 // remove redundant namespaces declarations
XML_PARSE_NOCDATA = 16384 // merge CDATA as text nodes
XML_PARSE_NOXINCNODE = 32768 // do not generate XINCLUDE START/END nodes
XML_PARSE_COMPACT = 65536 // compact small text nodes; no modification of the tree allowed afterwards (will possibly crash if you try to modify the tree)
XML_PARSE_OLD10 = 131072 // parse using XML-1.0 before update 5
XML_PARSE_NOBASEFIX = 262144 // do not fixup XINCLUDE xml//base uris
XML_PARSE_HUGE = 524288 // relax any hardcoded limit from the parser
XML_PARSE_OLDSAX = 1048576 // parse using SAX2 interface before 2.7.0
XML_PARSE_IGNORE_ENC = 2097152 // ignore internal document encoding hint
XML_PARSE_BIG_LINES = 4194304 // Store big lines numbers in text PSVI field
*/
const XSLT_PARSE_OPTIONS xml.ParseOption = 2 | 4 | 8 | 16384

func xmlReadFile(filename string) (doc *xml.XmlDocument, err error) {
data, err := ioutil.ReadFile(filename)
if err != nil {
return
}
doc, err = xml.Parse(data, xml.DefaultEncodingBytes, nil, XSLT_PARSE_OPTIONS, xml.DefaultEncodingBytes)
doc, err = xml.Parse(data, xml.DefaultEncodingBytes, nil, xml.StrictParseOption, xml.DefaultEncodingBytes)
return
}

0 comments on commit 0d5d883

Please sign in to comment.