summaryrefslogtreecommitdiffstats
path: root/xml/src/test/java
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2010-02-02 11:39:05 -0800
committerJesse Wilson <jessewilson@google.com>2010-02-10 15:18:15 -0800
commit2e4c40c282464cb5435b3078b8d375634355dbc1 (patch)
treec9f6fe174b70c0e8bc7e41ef01c67181f708a354 /xml/src/test/java
parent326600b64610c22fb4a34a62dcd45fe707148ce2 (diff)
downloadlibcore-2e4c40c282464cb5435b3078b8d375634355dbc1.zip
libcore-2e4c40c282464cb5435b3078b8d375634355dbc1.tar.gz
libcore-2e4c40c282464cb5435b3078b8d375634355dbc1.tar.bz2
Fixing some of our XSLT implementation issues.
These changes move our XSLT code to passing 1898/3173 of the OASIS tests. To contrast, the RI passes 2105/3173 tests. Highlights: - Implementing getTextContent() for nodes - Removing validation during transforms. We don't support validation! - Fixing attribute constraints to match the spec - Fixing test suite to not confuse BaseURI from NamespaceURI
Diffstat (limited to 'xml/src/test/java')
-rw-r--r--xml/src/test/java/org/apache/harmony/xml/XsltXPathConformanceTestSuite.java33
1 files changed, 20 insertions, 13 deletions
diff --git a/xml/src/test/java/org/apache/harmony/xml/XsltXPathConformanceTestSuite.java b/xml/src/test/java/org/apache/harmony/xml/XsltXPathConformanceTestSuite.java
index 7773814..443e415 100644
--- a/xml/src/test/java/org/apache/harmony/xml/XsltXPathConformanceTestSuite.java
+++ b/xml/src/test/java/org/apache/harmony/xml/XsltXPathConformanceTestSuite.java
@@ -78,7 +78,7 @@ public class XsltXPathConformanceTestSuite {
/** Orders element attributes by optional URI and name. */
private static final Comparator<Attr> orderByName = new Comparator<Attr>() {
public int compare(Attr a, Attr b) {
- int result = compareNullsFirst(a.getBaseURI(), b.getBaseURI());
+ int result = compareNullsFirst(a.getNamespaceURI(), b.getNamespaceURI());
return result == 0 ? result
: compareNullsFirst(a.getName(), b.getName());
}
@@ -322,6 +322,11 @@ public class XsltXPathConformanceTestSuite {
this.compareAs = compareAs;
}
+ XsltTest(File principalData, File principalStylesheet, File principal) {
+ this("standalone", "test", "", "",
+ principalData, principalStylesheet, principal, "standard", "XML");
+ }
+
public void test() throws Exception {
if (purpose != null) {
System.out.println("Purpose: " + purpose);
@@ -336,8 +341,8 @@ public class XsltXPathConformanceTestSuite {
Transformer transformer;
try {
transformer = transformerFactory.newTransformer(xslt);
- assertEquals("Expected transformer creation to fail",
- "standard", operation);
+ assertEquals("Transformer creation completed normally.",
+ operation, "standard");
} catch (TransformerConfigurationException e) {
if (operation.equals("execution-error")) {
return; // expected, such as in XSLT-Result-Tree.Attributes__78369
@@ -396,14 +401,17 @@ public class XsltXPathConformanceTestSuite {
}
private void emitNode(XmlSerializer serializer, Node node) throws IOException {
- if (node instanceof Element) {
+ if (node == null) {
+ throw new UnsupportedOperationException("Cannot emit null nodes");
+
+ } else if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) node;
- serializer.startTag(element.getBaseURI(), element.getLocalName());
+ serializer.startTag(element.getNamespaceURI(), element.getLocalName());
emitAttributes(serializer, element);
emitChildren(serializer, element);
- serializer.endTag(element.getBaseURI(), element.getLocalName());
+ serializer.endTag(element.getNamespaceURI(), element.getLocalName());
- } else if (node instanceof Text) {
+ } else if (node.getNodeType() == Node.TEXT_NODE) {
// TODO: is it okay to trim whitespace in general? This may cause
// false positives for elements like HTML's <pre> tag
String trimmed = node.getTextContent().trim();
@@ -411,25 +419,24 @@ public class XsltXPathConformanceTestSuite {
serializer.text(trimmed);
}
- } else if (node instanceof Document) {
+ } else if (node.getNodeType() == Node.DOCUMENT_NODE) {
Document document = (Document) node;
serializer.startDocument("UTF-8", true);
emitNode(serializer, document.getDocumentElement());
serializer.endDocument();
- } else if (node instanceof ProcessingInstruction) {
+ } else if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
ProcessingInstruction processingInstruction = (ProcessingInstruction) node;
String data = processingInstruction.getData();
String target = processingInstruction.getTarget();
serializer.processingInstruction(target + " " + data);
- } else if (node instanceof Comment) {
+ } else if (node.getNodeType() == Node.COMMENT_NODE) {
// ignore!
} else {
- Object nodeClass = node != null ? node.getClass() : null;
throw new UnsupportedOperationException(
- "Cannot serialize nodes of type " + nodeClass);
+ "Cannot emit " + node + " of type " + node.getNodeType());
}
}
@@ -458,7 +465,7 @@ public class XsltXPathConformanceTestSuite {
* generate one for us, using a predictable pattern.
*/
} else {
- serializer.attribute(attr.getBaseURI(), attr.getLocalName(), attr.getValue());
+ serializer.attribute(attr.getNamespaceURI(), attr.getLocalName(), attr.getValue());
}
}
}