|
Lines 6-12
Link Here
|
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
7 |
* |
| 8 |
* Contributors: |
8 |
* Contributors: |
| 9 |
* Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 |
9 |
* Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 |
|
|
10 |
* Mukul Gandhi - bug 276134 - improvements to schema aware primitive type support |
| 11 |
* for attribute/element nodes |
| 10 |
*******************************************************************************/ |
12 |
*******************************************************************************/ |
| 11 |
|
13 |
|
| 12 |
package org.eclipse.wst.xml.xpath2.processor; |
14 |
package org.eclipse.wst.xml.xpath2.processor; |
|
Lines 15-20
Link Here
|
| 15 |
|
17 |
|
| 16 |
import org.w3c.dom.*; |
18 |
import org.w3c.dom.*; |
| 17 |
import javax.xml.parsers.*; |
19 |
import javax.xml.parsers.*; |
|
|
20 |
import javax.xml.validation.Schema; |
| 21 |
|
| 18 |
import org.xml.sax.*; |
22 |
import org.xml.sax.*; |
| 19 |
|
23 |
|
| 20 |
/** |
24 |
/** |
|
Lines 41-53
Link Here
|
| 41 |
public static final String DOCUMENT_PSVI_IMPLEMENTATION = "org.apache.xerces.dom.PSVIDocumentImpl"; |
45 |
public static final String DOCUMENT_PSVI_IMPLEMENTATION = "org.apache.xerces.dom.PSVIDocumentImpl"; |
| 42 |
|
46 |
|
| 43 |
boolean _validating; |
47 |
boolean _validating; |
|
|
48 |
|
| 49 |
Schema _schema = null;; |
| 44 |
|
50 |
|
| 45 |
/** |
51 |
/** |
| 46 |
* Constructor for Xerxes loader. |
52 |
* Constructor for Xerces loader. |
| 47 |
*/ |
53 |
*/ |
| 48 |
public XercesLoader() { |
54 |
public XercesLoader() { |
| 49 |
_validating = false; |
55 |
_validating = false; |
| 50 |
} |
56 |
} |
|
|
57 |
|
| 58 |
/** |
| 59 |
* Constructor for Xerces Loader with a corresponding XML Schema |
| 60 |
* @param schema An XML Schema to use with the XML file. |
| 61 |
* @since 1.1 |
| 62 |
*/ |
| 63 |
public XercesLoader(Schema schema) { |
| 64 |
_validating = false; |
| 65 |
_schema = schema; |
| 66 |
} |
| 51 |
|
67 |
|
| 52 |
/** |
68 |
/** |
| 53 |
* The Xerces loader loads the XML docuemnt |
69 |
* The Xerces loader loads the XML docuemnt |
|
Lines 58-75
Link Here
|
| 58 |
* DOM loader exception. |
74 |
* DOM loader exception. |
| 59 |
* @return The loaded document. |
75 |
* @return The loaded document. |
| 60 |
*/ |
76 |
*/ |
| 61 |
// XXX: fix error reporting |
|
|
| 62 |
public Document load(InputStream in) throws DOMLoaderException { |
77 |
public Document load(InputStream in) throws DOMLoaderException { |
| 63 |
|
78 |
|
| 64 |
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
79 |
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
| 65 |
|
80 |
|
| 66 |
factory.setNamespaceAware(true); |
81 |
factory.setNamespaceAware(true); |
| 67 |
factory.setValidating(_validating); |
|
|
| 68 |
factory.setAttribute(SCHEMA_VALIDATION_FEATURE, |
82 |
factory.setAttribute(SCHEMA_VALIDATION_FEATURE, |
| 69 |
new Boolean(_validating)); |
83 |
new Boolean(_validating)); |
| 70 |
factory.setAttribute(DOCUMENT_IMPLEMENTATION_PROPERTY, |
84 |
factory.setAttribute(DOCUMENT_IMPLEMENTATION_PROPERTY, |
| 71 |
DOCUMENT_PSVI_IMPLEMENTATION); |
85 |
DOCUMENT_PSVI_IMPLEMENTATION); |
| 72 |
// factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); |
86 |
|
|
|
87 |
if (_schema != null) { |
| 88 |
factory.setSchema(_schema); |
| 89 |
} |
| 90 |
else { |
| 91 |
factory.setValidating(_validating); |
| 92 |
} |
| 73 |
|
93 |
|
| 74 |
try { |
94 |
try { |
| 75 |
DocumentBuilder builder = factory.newDocumentBuilder(); |
95 |
DocumentBuilder builder = factory.newDocumentBuilder(); |