Skip to content

Commit 0d5d883

Browse files
committed
Use ParserOption constants declared in gokogiri
1 parent 766b79c commit 0d5d883

File tree

2 files changed

+2
-29
lines changed

2 files changed

+2
-29
lines changed

ratago.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func xmlReadFile(filename string) (doc *xml.XmlDocument, err error) {
1515
if err != nil {
1616
return
1717
}
18-
doc, err = xml.Parse(data, xml.DefaultEncodingBytes, nil, xslt.XSLT_PARSE_OPTIONS, xml.DefaultEncodingBytes)
18+
doc, err = xml.Parse(data, xml.DefaultEncodingBytes, nil, xml.StrictParseOption, xml.DefaultEncodingBytes)
1919
return
2020
}
2121

xslt/util.go

+1-28
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,11 @@ import (
55
"io/ioutil"
66
)
77

8-
/*
9-
XML_PARSE_RECOVER = 1 // recover on errors
10-
XML_PARSE_NOENT = 2 // substitute entities
11-
XML_PARSE_DTDLOAD = 4 // load the external subset
12-
XML_PARSE_DTDATTR = 8 // default DTD attributes
13-
XML_PARSE_DTDVALID = 16 // validate with the DTD
14-
XML_PARSE_NOERROR = 32 // suppress error reports
15-
XML_PARSE_NOWARNING = 64 // suppress warning reports
16-
XML_PARSE_PEDANTIC = 128 // pedantic error reporting
17-
XML_PARSE_NOBLANKS = 256 // remove blank nodes
18-
XML_PARSE_SAX1 = 512 // use the SAX1 interface internally
19-
XML_PARSE_XINCLUDE = 1024 // Implement XInclude substitition
20-
XML_PARSE_NONET = 2048 // Forbid network access
21-
XML_PARSE_NODICT = 4096 // Do not reuse the context dictionnary
22-
XML_PARSE_NSCLEAN = 8192 // remove redundant namespaces declarations
23-
XML_PARSE_NOCDATA = 16384 // merge CDATA as text nodes
24-
XML_PARSE_NOXINCNODE = 32768 // do not generate XINCLUDE START/END nodes
25-
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)
26-
XML_PARSE_OLD10 = 131072 // parse using XML-1.0 before update 5
27-
XML_PARSE_NOBASEFIX = 262144 // do not fixup XINCLUDE xml//base uris
28-
XML_PARSE_HUGE = 524288 // relax any hardcoded limit from the parser
29-
XML_PARSE_OLDSAX = 1048576 // parse using SAX2 interface before 2.7.0
30-
XML_PARSE_IGNORE_ENC = 2097152 // ignore internal document encoding hint
31-
XML_PARSE_BIG_LINES = 4194304 // Store big lines numbers in text PSVI field
32-
*/
33-
const XSLT_PARSE_OPTIONS xml.ParseOption = 2 | 4 | 8 | 16384
34-
358
func xmlReadFile(filename string) (doc *xml.XmlDocument, err error) {
369
data, err := ioutil.ReadFile(filename)
3710
if err != nil {
3811
return
3912
}
40-
doc, err = xml.Parse(data, xml.DefaultEncodingBytes, nil, XSLT_PARSE_OPTIONS, xml.DefaultEncodingBytes)
13+
doc, err = xml.Parse(data, xml.DefaultEncodingBytes, nil, xml.StrictParseOption, xml.DefaultEncodingBytes)
4114
return
4215
}

0 commit comments

Comments
 (0)