|
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-46
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 Xerxes loader. |
|
Lines 48-53
Link Here
|
| 48 |
public XercesLoader() { |
54 |
public XercesLoader() { |
| 49 |
_validating = false; |
55 |
_validating = false; |
| 50 |
} |
56 |
} |
|
|
57 |
|
| 58 |
public XercesLoader(Schema schema) { |
| 59 |
_validating = false; |
| 60 |
_schema = schema; |
| 61 |
} |
| 51 |
|
62 |
|
| 52 |
/** |
63 |
/** |
| 53 |
* The Xerces loader loads the XML docuemnt |
64 |
* The Xerces loader loads the XML docuemnt |
|
Lines 64-75
Link Here
|
| 64 |
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
75 |
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
| 65 |
|
76 |
|
| 66 |
factory.setNamespaceAware(true); |
77 |
factory.setNamespaceAware(true); |
| 67 |
factory.setValidating(_validating); |
|
|
| 68 |
factory.setAttribute(SCHEMA_VALIDATION_FEATURE, |
78 |
factory.setAttribute(SCHEMA_VALIDATION_FEATURE, |
| 69 |
new Boolean(_validating)); |
79 |
new Boolean(_validating)); |
| 70 |
factory.setAttribute(DOCUMENT_IMPLEMENTATION_PROPERTY, |
80 |
factory.setAttribute(DOCUMENT_IMPLEMENTATION_PROPERTY, |
| 71 |
DOCUMENT_PSVI_IMPLEMENTATION); |
81 |
DOCUMENT_PSVI_IMPLEMENTATION); |
| 72 |
// factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); |
82 |
|
|
|
83 |
if (_schema != null) { |
| 84 |
factory.setSchema(_schema); |
| 85 |
} |
| 86 |
else { |
| 87 |
factory.setValidating(_validating); |
| 88 |
} |
| 73 |
|
89 |
|
| 74 |
try { |
90 |
try { |
| 75 |
DocumentBuilder builder = factory.newDocumentBuilder(); |
91 |
DocumentBuilder builder = factory.newDocumentBuilder(); |
|
Lines 94-106
Link Here
|
| 94 |
} |
110 |
} |
| 95 |
return builder.parse(in); |
111 |
return builder.parse(in); |
| 96 |
} catch (SAXException e) { |
112 |
} catch (SAXException e) { |
| 97 |
throw new DOMLoaderException("SAX exception: " + e.getMessage()); |
113 |
//throw new DOMLoaderException("SAX exception: " + e.getMessage()); |
|
|
114 |
e.printStackTrace(); |
| 98 |
} catch (ParserConfigurationException e) { |
115 |
} catch (ParserConfigurationException e) { |
| 99 |
throw new DOMLoaderException("Parser configuration exception: " |
116 |
throw new DOMLoaderException("Parser configuration exception: " |
| 100 |
+ e.getMessage()); |
117 |
+ e.getMessage()); |
| 101 |
} catch (IOException e) { |
118 |
} catch (IOException e) { |
| 102 |
throw new DOMLoaderException("IO exception: " + e.getMessage()); |
119 |
throw new DOMLoaderException("IO exception: " + e.getMessage()); |
| 103 |
} |
120 |
} |
|
|
121 |
|
| 122 |
return null; |
| 104 |
|
123 |
|
| 105 |
} |
124 |
} |
| 106 |
|
125 |
|