Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 276134 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/wst/xml/xpath2/processor/test/AbstractPsychoPathTest.java (+21 lines)
Lines 20-25 Link Here
20
import java.util.regex.Matcher;
20
import java.util.regex.Matcher;
21
import java.util.regex.Pattern;
21
import java.util.regex.Pattern;
22
22
23
import javax.xml.XMLConstants;
24
import javax.xml.transform.stream.StreamSource;
25
import javax.xml.validation.Schema;
26
import javax.xml.validation.SchemaFactory;
27
23
import org.apache.xerces.xs.ElementPSVI;
28
import org.apache.xerces.xs.ElementPSVI;
24
import org.apache.xerces.xs.XSModel;
29
import org.apache.xerces.xs.XSModel;
25
import org.eclipse.core.runtime.Platform;
30
import org.eclipse.core.runtime.Platform;
Lines 31-36 Link Here
31
import org.eclipse.wst.xml.xpath2.processor.internal.types.QName;
36
import org.eclipse.wst.xml.xpath2.processor.internal.types.QName;
32
import org.osgi.framework.Bundle;
37
import org.osgi.framework.Bundle;
33
import org.w3c.dom.Document;
38
import org.w3c.dom.Document;
39
import org.xml.sax.SAXException;
34
40
35
import junit.framework.TestCase;
41
import junit.framework.TestCase;
36
42
Lines 64-69 Link Here
64
		domloader.set_validating(false);
70
		domloader.set_validating(false);
65
		domDoc = domloader.load(is);
71
		domDoc = domloader.load(is);
66
	}
72
	}
73
	
74
	protected void loadDOMDocument(URL fileURL, URL schemaURL) throws Exception {
75
	     InputStream is = fileURL.openStream();
76
	      InputStream schemaIs = schemaURL.openStream();
77
	      DOMLoader domloader = new XercesLoader(getSchema(schemaIs));
78
	      domDoc = domloader.load(is);
79
	    }
80
		
81
		private Schema getSchema(InputStream schemaIs) throws SAXException {
82
			SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
83
	        Schema schema = sf.newSchema(new StreamSource(schemaIs));
84
	        
85
	        return schema;
86
		}
87
67
88
68
	@Override
89
	@Override
69
	protected void tearDown() throws Exception {
90
	protected void tearDown() throws Exception {
(-)src/org/eclipse/wst/xml/xpath2/processor/test/TestBugs.java (+50 lines)
Lines 375-378 Link Here
375
		assertEquals("true", actual);
375
		assertEquals("true", actual);
376
	}
376
	}
377
	
377
	
378
	public void testSchemaAwarenessForAttributes() throws Exception {
379
			// Bug 276134
380
			URL fileURL = bundle.getEntry("/bugTestFiles/bug276134.xml");
381
			URL schemaURL = bundle.getEntry("/bugTestFiles/bug276134.xsd");
382
	
383
			loadDOMDocument(fileURL, schemaURL);
384
			
385
			// Get XSModel object for the Schema
386
			XSModel schema = getGrammar();
387
	
388
			DynamicContext dc = setupDynamicContext(schema);
389
			
390
			String xpath = "person/@dob eq xs:date('2006-12-10')";
391
			XPath path = compileXPath(dc, xpath);
392
	
393
			Evaluator eval = new DefaultEvaluator(dc, domDoc);
394
			ResultSequence rs = eval.evaluate(path);
395
	
396
			XSBoolean result = (XSBoolean) rs.first();
397
	
398
			String actual = result.string_value();
399
	
400
			assertEquals("true", actual);
401
		}
402
		
403
		public void testSchemaAwarenessForElements() throws Exception {
404
			// Bug 276134
405
			URL fileURL = bundle.getEntry("/bugTestFiles/bug276134_2.xml");
406
			URL schemaURL = bundle.getEntry("/bugTestFiles/bug276134_2.xsd");
407
	
408
			loadDOMDocument(fileURL, schemaURL);
409
			
410
			// Get XSModel object for the Schema
411
			XSModel schema = getGrammar();
412
	
413
			DynamicContext dc = setupDynamicContext(schema);
414
			
415
			String xpath = "person/dob eq xs:date('2006-12-10')";
416
			XPath path = compileXPath(dc, xpath);
417
	
418
			Evaluator eval = new DefaultEvaluator(dc, domDoc);
419
			ResultSequence rs = eval.evaluate(path);
420
	
421
			XSBoolean result = (XSBoolean) rs.first();
422
	
423
			String actual = result.string_value();
424
	
425
			assertEquals("true", actual);
426
		}
427
	
378
}
428
}
(-).settings/org.eclipse.core.resources.prefs (-1 / +3 lines)
Lines 1-3 Link Here
1
#Tue Apr 28 23:45:15 GMT 2009
1
#Sat May 23 15:26:34 GMT 2009
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
encoding//bugTestFiles/bug276134.xsd=UTF8
4
encoding//bugTestFiles/bug276134_2.xsd=UTF8
3
encoding/XQTSCatalog.xsd=UTF8
5
encoding/XQTSCatalog.xsd=UTF8
(-)bugTestFiles/bug276134_2.xsd (+27 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<!-- 
3
/*******************************************************************************
4
 * Copyright (c) 2009 Mukul Gandhi and others.
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 * 
10
 * Contributors:
11
 *     Mukul Gandhi - bug 276134 - initial API and implementation
12
 *******************************************************************************
13
 -->
14
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
15
 
16
  <xs:element name="person">
17
   <xs:complexType>
18
    <xs:sequence>
19
     <xs:element name="id" type="xs:integer"/>
20
     <xs:element name="fname" type="xs:string"/>
21
     <xs:element name="lname" type="xs:string"/>
22
     <xs:element name="dob" type="xs:date"/>
23
    </xs:sequence>
24
   </xs:complexType>
25
  </xs:element>
26
 
27
</xs:schema>
(-)bugTestFiles/bug276134.xml (+18 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
3
<!-- 
4
/*******************************************************************************
5
 * Copyright (c) 2009 Mukul Gandhi and others.
6
 * All rights reserved. This program and the accompanying materials
7
 * are made available under the terms of the Eclipse Public License v1.0
8
 * which accompanies this distribution, and is available at
9
 * http://www.eclipse.org/legal/epl-v10.html
10
 * 
11
 * Contributors:
12
 *     Mukul Gandhi - bug 276134 - initial API and implementation
13
 *******************************************************************************
14
 -->
15
<person id="100" dob="2006-12-10" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
16
  <fname>Mukul</fname>
17
  <lname>Gandhi</lname>
18
</person>
(-)bugTestFiles/bug276134.xsd (+27 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!-- 
3
/*******************************************************************************
4
 * Copyright (c) 2009 Mukul Gandhi and others.
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 * 
10
 * Contributors:
11
 *     Mukul Gandhi - bug 276134 - initial API and implementation
12
 *******************************************************************************
13
 -->
14
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
15
 
16
  <xs:element name="person">
17
   <xs:complexType>
18
    <xs:sequence>
19
     <xs:element name="fname" type = "xs:string" />
20
     <xs:element name="lname" type = "xs:string" />
21
    </xs:sequence>
22
    <xs:attribute name="id" type="xs:integer" />
23
    <xs:attribute name="dob" type="xs:date" />
24
   </xs:complexType>
25
  </xs:element>
26
 
27
</xs:schema>
(-)bugTestFiles/bug276134_2.xml (+19 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!-- 
3
/*******************************************************************************
4
 * Copyright (c) 2009 Mukul Gandhi and others.
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 * 
10
 * Contributors:
11
 *     Mukul Gandhi - bug 276134 - initial API and implementation
12
 *******************************************************************************
13
 -->
14
<person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
15
  <id>100</id>
16
  <fname>Mukul</fname>
17
  <lname>Gandhi</lname>
18
  <dob>2006-12-10</dob>
19
</person>
(-)NewFile.xml (+1 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/AttrType.java (-7 / +23 lines)
Lines 6-20 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.internal.types;
14
package org.eclipse.wst.xml.xpath2.processor.internal.types;
13
15
14
import org.w3c.dom.*;
16
import org.apache.xerces.dom.PSVIAttrNSImpl;
17
import org.apache.xerces.xs.XSTypeDefinition;
15
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
17
import org.eclipse.wst.xml.xpath2.processor.internal.*;
20
import org.eclipse.wst.xml.xpath2.processor.function.XSCtrLibrary;
21
import org.w3c.dom.Attr;
18
22
19
/**
23
/**
20
 * A representation of the AttributeType datatype
24
 * A representation of the AttributeType datatype
Lines 72-81 Link Here
72
	@Override
76
	@Override
73
	public ResultSequence typed_value() {
77
	public ResultSequence typed_value() {
74
		ResultSequence rs = ResultSequenceFactory.create_new();
78
		ResultSequence rs = ResultSequenceFactory.create_new();
75
79
		
76
		// XXX with no PSVI
80
		PSVIAttrNSImpl psviAttr = (PSVIAttrNSImpl)_value;
77
		rs.add(new UntypedAtomic(string_value()));
81
		XSTypeDefinition typeDef = psviAttr.getTypeDefinition();
78
82
		
83
		if (typeDef != null && typeDef.getNamespace().equals(XSCtrLibrary.XML_SCHEMA_NS)) {
84
		  Object schemaTypeValue = getTypedValueForPrimitiveType(typeDef);
85
		  if (schemaTypeValue != null) {
86
			rs.add((AnyType)schemaTypeValue);  
87
		  }
88
		  else {
89
			rs.add(new UntypedAtomic(string_value()));  
90
		  }
91
	    } else {
92
		   rs.add(new UntypedAtomic(string_value()));	
93
		}
94
		
79
		return rs;
95
		return rs;
80
	}
96
	}
81
97
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/ElementType.java (-7 / +26 lines)
Lines 6-20 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.internal.types;
14
package org.eclipse.wst.xml.xpath2.processor.internal.types;
13
15
14
import org.w3c.dom.*;
16
import org.apache.xerces.dom.PSVIElementNSImpl;
17
import org.apache.xerces.xs.XSTypeDefinition;
15
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
17
import org.eclipse.wst.xml.xpath2.processor.internal.*;
20
import org.eclipse.wst.xml.xpath2.processor.function.XSCtrLibrary;
21
import org.w3c.dom.Element;
22
import org.w3c.dom.Node;
23
import org.w3c.dom.NodeList;
24
import org.w3c.dom.Text;
18
25
19
/**
26
/**
20
 * A representation of the ElementType datatype
27
 * A representation of the ElementType datatype
Lines 90-99 Link Here
90
	 */
97
	 */
91
	@Override
98
	@Override
92
	public ResultSequence typed_value() {
99
	public ResultSequence typed_value() {
93
		ResultSequence rs = ResultSequenceFactory.create_new();
100
		ResultSequence rs = ResultSequenceFactory.create_new();	
94
101
		
95
		// XXX only if PSVI is not present!! [not our case]
102
		PSVIElementNSImpl psviElem = (PSVIElementNSImpl)_value;
96
		rs.add(new UntypedAtomic(string_value()));
103
		XSTypeDefinition typeDef = psviElem.getTypeDefinition();
104
		
105
		if (typeDef != null && typeDef.getNamespace().equals(XSCtrLibrary.XML_SCHEMA_NS)) {
106
		  Object schemaTypeValue = getTypedValueForPrimitiveType(typeDef);
107
		  if (schemaTypeValue != null) {
108
			rs.add((AnyType)schemaTypeValue);  
109
		  }
110
		  else {
111
			rs.add(new UntypedAtomic(string_value()));  
112
		  }
113
	    } else {
114
		   rs.add(new UntypedAtomic(string_value()));	
115
		}	
97
116
98
		return rs;
117
		return rs;
99
	}
118
	}
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/NodeType.java (-5 / +44 lines)
Lines 6-22 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.internal.types;
14
package org.eclipse.wst.xml.xpath2.processor.internal.types;
13
15
14
import org.w3c.dom.*;
16
import java.math.BigInteger;
17
import java.util.ArrayList;
18
import java.util.Hashtable;
19
import java.util.Iterator;
20
21
import org.apache.xerces.xs.XSTypeDefinition;
15
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
22
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
23
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
17
import org.eclipse.wst.xml.xpath2.processor.internal.*;
24
import org.w3c.dom.Attr;
18
25
import org.w3c.dom.Comment;
19
import java.util.*;
26
import org.w3c.dom.Document;
27
import org.w3c.dom.Element;
28
import org.w3c.dom.Node;
29
import org.w3c.dom.ProcessingInstruction;
30
import org.w3c.dom.Text;
20
31
21
/**
32
/**
22
 * A representation of a Node datatype
33
 * A representation of a Node datatype
Lines 175-178 Link Here
175
186
176
		return !before(a, b);
187
		return !before(a, b);
177
	}
188
	}
189
	
190
	protected Object getTypedValueForPrimitiveType(XSTypeDefinition typeDef) {		
191
		Object schemaTypeValue = null;
192
		
193
		if (typeDef.getName().equals("date")) {		
194
		   schemaTypeValue = XSDate.parse_date(string_value());
195
		}
196
		else if (typeDef.getName().equals("int")) {		
197
		   schemaTypeValue = new XSInt(new BigInteger(string_value()));
198
		}
199
		else if (typeDef.getName().equals("long")) {		
200
		  schemaTypeValue = new XSLong(new BigInteger(string_value()));
201
	    }
202
		else if (typeDef.getName().equals("integer")) {		
203
		  schemaTypeValue = new XSInteger(new BigInteger(string_value()));
204
		}
205
		else if (typeDef.getName().equals("double")) {		
206
		  schemaTypeValue = new XSDouble(Double.parseDouble(string_value()));
207
		}
208
		else if (typeDef.getName().equals("float")) {		
209
		  schemaTypeValue = new XSFloat(Float.parseFloat(string_value()));
210
	    }
211
		else if (typeDef.getName().equals("decimal")) {		
212
		  schemaTypeValue = new XSDecimal(Double.parseDouble(string_value()));
213
		}
214
		
215
		return schemaTypeValue;
216
	}
178
}
217
}
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnData.java (-8 / +15 lines)
Lines 6-22 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.internal.function;
14
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
15
16
import java.util.Collection;
17
import java.util.Iterator;
18
import java.util.ListIterator;
19
14
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
20
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
15
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
21
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
16
import org.eclipse.wst.xml.xpath2.processor.internal.*;
22
import org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType;
17
import org.eclipse.wst.xml.xpath2.processor.internal.types.*;
23
import org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType;
18
24
import org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType;
19
import java.util.*;
25
import org.eclipse.wst.xml.xpath2.processor.internal.types.QName;
20
26
21
/**
27
/**
22
 * fn:data takes a sequence of items and returns a sequence of atomic values.
28
 * fn:data takes a sequence of items and returns a sequence of atomic values.
Lines 65-78 Link Here
65
		for (Iterator i = arg.iterator(); i.hasNext();) {
71
		for (Iterator i = arg.iterator(); i.hasNext();) {
66
			AnyType at = (AnyType) i.next();
72
			AnyType at = (AnyType) i.next();
67
73
68
			if (at instanceof AnyAtomicType)
74
			if (at instanceof AnyAtomicType) {
69
				rs.add(at);
75
				rs.add(at);
76
			}
70
			else if (at instanceof NodeType) {
77
			else if (at instanceof NodeType) {
71
				NodeType nt = (NodeType) at;
78
				NodeType nt = (NodeType) at;
72
73
				rs.concat(nt.typed_value());
79
				rs.concat(nt.typed_value());
74
			} else
80
			} else {
75
				assert false;
81
				assert false;
82
			}
76
		}
83
		}
77
84
78
		return rs;
85
		return rs;
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/FsEq.java (-2 / +5 lines)
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.internal.function;
14
package org.eclipse.wst.xml.xpath2.processor.internal.function;
Lines 64-70 Link Here
64
		for (Iterator i = args.iterator(); i.hasNext();) {
66
		for (Iterator i = args.iterator(); i.hasNext();) {
65
			ResultSequence rs = (ResultSequence) i.next();
67
			ResultSequence rs = (ResultSequence) i.next();
66
68
67
			FnData.fast_atomize(rs);
69
			//FnData.fast_atomize(rs);
70
			rs = FnData.atomize(rs);
68
71
69
			if (rs.empty())
72
			if (rs.empty())
70
				return new ArrayList();
73
				return new ArrayList();
(-)src/org/eclipse/wst/xml/xpath2/processor/XercesLoader.java (-5 / +25 lines)
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();

Return to bug 276134