Permalink
Browse files

Merge pull request #299 from dizzzz/misc-fixes

Misc late minor fixes
  • Loading branch information...
2 parents e140aa6 + 34162da commit 9b0db0de18ac224c5c92e5878c7cb715cd54eb30 @wolfgangmm wolfgangmm committed Aug 15, 2014
Showing with 57 additions and 51 deletions.
  1. +1 −1 README.md
  2. +2 −2 build.properties
  3. +53 −47 src/org/exist/xquery/functions/fn/ParsingFunctions.java
  4. +1 −1 test/src/xquery/util/util.xml
View
@@ -17,7 +17,7 @@ If you wish to work on the eXist source code we're now using [Git](http://git-sc
Building eXist from Source
--------------------------
-eXist itself is written predominantly in Java 6. The build system is [Apache Ant](http://ant.apache.org/ "The Apache Ant Project").
+eXist itself is written in Java 7. The build system is [Apache Ant](http://ant.apache.org/ "The Apache Ant Project").
To build eXist:
View
@@ -4,8 +4,8 @@
#
# $Id$
project.name = eXist-db
-project.version = 2.1
-project.version.numeric = 2.1
+project.version = 2.2
+project.version.numeric = 2.2
project.codename = Ruesselsheim
# build settings
@@ -94,52 +94,58 @@ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathExce
xmlContent = "<root>" + xmlContent + "</root>";
}
- final StringReader reader = new StringReader(xmlContent);
- final ValidationReport report = new ValidationReport();
- final SAXAdapter adapter = new SAXAdapter(context);
- try {
- final SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setNamespaceAware(true);
- final InputSource src = new InputSource(reader);
-
- XMLReader xr = null;
-
- if (xr == null) {
- final SAXParser parser = factory.newSAXParser();
- xr = parser.getXMLReader();
- }
-
- xr.setErrorHandler(report);
- xr.setContentHandler(adapter);
- xr.setProperty(Namespaces.SAX_LEXICAL_HANDLER, adapter);
- xr.parse(src);
- } catch (final ParserConfigurationException e) {
- throw new XPathException(this, ErrorCodes.EXXQDY0002, "Error while constructing XML parser: "
- + e.getMessage(), args[0], e);
- } catch (final SAXException e) {
- logger.debug("Error while parsing XML: " + e.getMessage(), e);
- } catch (final IOException e) {
- throw new XPathException(this, ErrorCodes.FODC0006, ErrorCodes.FODC0006.getDescription() + ": " + e.getMessage(),
- args[0], e);
- }
-
- if (report.isValid()) {
- if (isCalledAs("parse-xml-fragment")) {
- resultSequence = new ValueSequence();
- NodeList children = adapter.getDocument().getDocumentElement().getChildNodes();
- for (int i = 0, il = children.getLength(); i < il; i++) {
- Node child = children.item(i);
- resultSequence.add((NodeValue)child);
- }
-
- return resultSequence;
- } else {
- return (DocumentImpl) adapter.getDocument();
- }
- } else {
- final MemTreeBuilder builder = context.getDocumentBuilder();
- final NodeImpl result = Shared.writeReport(report, builder);
- throw new XPathException(this, ErrorCodes.FODC0006, ErrorCodes.FODC0006.getDescription() + ": " + report.toString(), result);
- }
+ final StringReader reader = new StringReader(xmlContent);
+ final InputSource src = new InputSource(reader);
+
+ return parse(src, context, args);
}
+
+ private Sequence parse(final InputSource src, XQueryContext theContext, Sequence[] args) throws XPathException {
+ Sequence resultSequence;
+ final ValidationReport report = new ValidationReport();
+ final SAXAdapter adapter = new SAXAdapter(theContext);
+ try {
+ final SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(true);
+
+ XMLReader xr = null;
+
+ if (xr == null) {
+ final SAXParser parser = factory.newSAXParser();
+ xr = parser.getXMLReader();
+ }
+
+ xr.setErrorHandler(report);
+ xr.setContentHandler(adapter);
+ xr.setProperty(Namespaces.SAX_LEXICAL_HANDLER, adapter);
+ xr.parse(src);
+
+ } catch (final ParserConfigurationException e) {
+ throw new XPathException(this, ErrorCodes.EXXQDY0002, "Error while constructing XML parser: " + e.getMessage(), args[0], e);
+ } catch (final SAXException e) {
+ logger.debug("Error while parsing XML: " + e.getMessage(), e);
+ } catch (final IOException e) {
+ throw new XPathException(this, ErrorCodes.FODC0006, ErrorCodes.FODC0006.getDescription() + ": " + e.getMessage(),
+ args[0], e);
+ }
+
+ if (report.isValid()) {
+ if (isCalledAs("parse-xml-fragment")) {
+ resultSequence = new ValueSequence();
+ NodeList children = adapter.getDocument().getDocumentElement().getChildNodes();
+ for (int i = 0, il = children.getLength(); i < il; i++) {
+ Node child = children.item(i);
+ resultSequence.add((NodeValue)child);
+ }
+
+ return resultSequence;
+ } else {
+ return (DocumentImpl) adapter.getDocument();
+ }
+ } else {
+ final MemTreeBuilder builder = theContext.getDocumentBuilder();
+ final NodeImpl result = Shared.writeReport(report, builder);
+ throw new XPathException(this, ErrorCodes.FODC0006, ErrorCodes.FODC0006.getDescription() + ": " + report.toString(), result);
+ }
+ }
}
@@ -269,7 +269,7 @@ return
<test output="text">
<task>util:system-property</task>
<code>util:system-property("vendor")</code>
- <expected>eXist Project</expected>
+ <expected>eXist-db Project</expected>
</test>
<test output="text">
<task>util:system-property</task>

0 comments on commit 9b0db0d

Please sign in to comment.