@Test public void parseTextWithNullInstruction() throws Throwable { URL url = this.getClass().getResource("/jabberwocky.txt"); URLConnection urlConn = url.openConnection(); TECore iut = new TECore(engine, index, runOpts); Element result = iut.parse(urlConn, null); Element content = (Element) result.getElementsByTagName("content") .item(0); assertNotNull("Expected content element.", content); assertTrue("Expected text content starting with 'Twas brillig", content .getTextContent().startsWith("'Twas brillig")); }
public Element parse(Document parse_instruction, String xsl_version) throws Throwable { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); dbf.setExpandEntityReferences(false); DocumentBuilder db = dbf.newDocumentBuilder(); TransformerFactory tf = TransformerFactory.newInstance(); tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); Transformer t = null; Node content = null; Document parser_instruction = null; Element parse_element = (Element) parse_instruction .getElementsByTagNameNS(CTL_NS, "parse").item(0); NodeList children = parse_element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeType() == Node.ELEMENT_NODE) { Element e = (Element) children.item(i); if (e.getNamespaceURI().equals(XSL_NS) && e.getLocalName().equals("output")) { Document doc = db.newDocument(); Element transform = doc .createElementNS(XSL_NS, "transform"); transform.setAttribute("version", xsl_version); doc.appendChild(transform); Element output = doc.createElementNS(XSL_NS, "output"); NamedNodeMap atts = e.getAttributes(); for (int j = 0; j < atts.getLength(); j++) { Attr a = (Attr) atts.item(i); output.setAttribute(a.getName(), a.getValue()); } transform.appendChild(output); Element template = doc.createElementNS(XSL_NS, "template"); template.setAttribute("match", "node()|@*"); transform.appendChild(template); Element copy = doc.createElementNS(XSL_NS, "copy"); template.appendChild(copy); Element apply = doc.createElementNS(XSL_NS, "apply-templates"); apply.setAttribute("select", "node()|@*"); copy.appendChild(apply); t = tf.newTransformer(new DOMSource(doc)); } else if (e.getLocalName().equals("content")) { NodeList children2 = e.getChildNodes(); for (int j = 0; j < children2.getLength(); j++) { if (children2.item(j).getNodeType() == Node.ELEMENT_NODE) { content = children2.item(j); } } if (content == null) { content = children2.item(0); } } else { parser_instruction = db.newDocument(); tf.newTransformer().transform(new DOMSource(e), new DOMResult(parser_instruction)); } } } if (t == null) { t = tf.newTransformer(); } File temp = File.createTempFile("$te_", ".xml"); if (content != null && content.getNodeType() == Node.TEXT_NODE) { RandomAccessFile raf = new RandomAccessFile(temp, "rw"); raf.writeBytes(((Text) content).getTextContent()); raf.close(); } else { t.transform(new DOMSource(content), new StreamResult(temp)); } URLConnection uc = temp.toURI().toURL().openConnection(); Element result = parse(uc, parser_instruction); temp.delete(); return result; }
TECore implements Runnable { public Element parse(Document parse_instruction, String xsl_version) throws Throwable { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); dbf.setExpandEntityReferences(false); DocumentBuilder db = dbf.newDocumentBuilder(); TransformerFactory tf = TransformerFactory.newInstance(); tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); Transformer t = null; Node content = null; Document parser_instruction = null; Element parse_element = (Element) parse_instruction .getElementsByTagNameNS(CTL_NS, "parse").item(0); NodeList children = parse_element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeType() == Node.ELEMENT_NODE) { Element e = (Element) children.item(i); if (e.getNamespaceURI().equals(XSL_NS) && e.getLocalName().equals("output")) { Document doc = db.newDocument(); Element transform = doc .createElementNS(XSL_NS, "transform"); transform.setAttribute("version", xsl_version); doc.appendChild(transform); Element output = doc.createElementNS(XSL_NS, "output"); NamedNodeMap atts = e.getAttributes(); for (int j = 0; j < atts.getLength(); j++) { Attr a = (Attr) atts.item(i); output.setAttribute(a.getName(), a.getValue()); } transform.appendChild(output); Element template = doc.createElementNS(XSL_NS, "template"); template.setAttribute("match", "node()|@*"); transform.appendChild(template); Element copy = doc.createElementNS(XSL_NS, "copy"); template.appendChild(copy); Element apply = doc.createElementNS(XSL_NS, "apply-templates"); apply.setAttribute("select", "node()|@*"); copy.appendChild(apply); t = tf.newTransformer(new DOMSource(doc)); } else if (e.getLocalName().equals("content")) { NodeList children2 = e.getChildNodes(); for (int j = 0; j < children2.getLength(); j++) { if (children2.item(j).getNodeType() == Node.ELEMENT_NODE) { content = children2.item(j); } } if (content == null) { content = children2.item(0); } } else { parser_instruction = db.newDocument(); tf.newTransformer().transform(new DOMSource(e), new DOMResult(parser_instruction)); } } } if (t == null) { t = tf.newTransformer(); } File temp = File.createTempFile("$te_", ".xml"); if (content != null && content.getNodeType() == Node.TEXT_NODE) { RandomAccessFile raf = new RandomAccessFile(temp, "rw"); raf.writeBytes(((Text) content).getTextContent()); raf.close(); } else { t.transform(new DOMSource(content), new StreamResult(temp)); } URLConnection uc = temp.toURI().toURL().openConnection(); Element result = parse(uc, parser_instruction); temp.delete(); return result; } }
TECore implements Runnable { public Element parse(Document parse_instruction, String xsl_version) throws Throwable { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); dbf.setExpandEntityReferences(false); DocumentBuilder db = dbf.newDocumentBuilder(); TransformerFactory tf = TransformerFactory.newInstance(); tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); Transformer t = null; Node content = null; Document parser_instruction = null; Element parse_element = (Element) parse_instruction .getElementsByTagNameNS(CTL_NS, "parse").item(0); NodeList children = parse_element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeType() == Node.ELEMENT_NODE) { Element e = (Element) children.item(i); if (e.getNamespaceURI().equals(XSL_NS) && e.getLocalName().equals("output")) { Document doc = db.newDocument(); Element transform = doc .createElementNS(XSL_NS, "transform"); transform.setAttribute("version", xsl_version); doc.appendChild(transform); Element output = doc.createElementNS(XSL_NS, "output"); NamedNodeMap atts = e.getAttributes(); for (int j = 0; j < atts.getLength(); j++) { Attr a = (Attr) atts.item(i); output.setAttribute(a.getName(), a.getValue()); } transform.appendChild(output); Element template = doc.createElementNS(XSL_NS, "template"); template.setAttribute("match", "node()|@*"); transform.appendChild(template); Element copy = doc.createElementNS(XSL_NS, "copy"); template.appendChild(copy); Element apply = doc.createElementNS(XSL_NS, "apply-templates"); apply.setAttribute("select", "node()|@*"); copy.appendChild(apply); t = tf.newTransformer(new DOMSource(doc)); } else if (e.getLocalName().equals("content")) { NodeList children2 = e.getChildNodes(); for (int j = 0; j < children2.getLength(); j++) { if (children2.item(j).getNodeType() == Node.ELEMENT_NODE) { content = children2.item(j); } } if (content == null) { content = children2.item(0); } } else { parser_instruction = db.newDocument(); tf.newTransformer().transform(new DOMSource(e), new DOMResult(parser_instruction)); } } } if (t == null) { t = tf.newTransformer(); } File temp = File.createTempFile("$te_", ".xml"); if (content != null && content.getNodeType() == Node.TEXT_NODE) { RandomAccessFile raf = new RandomAccessFile(temp, "rw"); raf.writeBytes(((Text) content).getTextContent()); raf.close(); } else { t.transform(new DOMSource(content), new StreamResult(temp)); } URLConnection uc = temp.toURI().toURL().openConnection(); Element result = parse(uc, parser_instruction); temp.delete(); return result; } TECore();  TECore(Engine engine, Index index, RuntimeOptions opts); }
TECore implements Runnable { public Element parse(Document parse_instruction, String xsl_version) throws Throwable { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); dbf.setExpandEntityReferences(false); DocumentBuilder db = dbf.newDocumentBuilder(); TransformerFactory tf = TransformerFactory.newInstance(); tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); Transformer t = null; Node content = null; Document parser_instruction = null; Element parse_element = (Element) parse_instruction .getElementsByTagNameNS(CTL_NS, "parse").item(0); NodeList children = parse_element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeType() == Node.ELEMENT_NODE) { Element e = (Element) children.item(i); if (e.getNamespaceURI().equals(XSL_NS) && e.getLocalName().equals("output")) { Document doc = db.newDocument(); Element transform = doc .createElementNS(XSL_NS, "transform"); transform.setAttribute("version", xsl_version); doc.appendChild(transform); Element output = doc.createElementNS(XSL_NS, "output"); NamedNodeMap atts = e.getAttributes(); for (int j = 0; j < atts.getLength(); j++) { Attr a = (Attr) atts.item(i); output.setAttribute(a.getName(), a.getValue()); } transform.appendChild(output); Element template = doc.createElementNS(XSL_NS, "template"); template.setAttribute("match", "node()|@*"); transform.appendChild(template); Element copy = doc.createElementNS(XSL_NS, "copy"); template.appendChild(copy); Element apply = doc.createElementNS(XSL_NS, "apply-templates"); apply.setAttribute("select", "node()|@*"); copy.appendChild(apply); t = tf.newTransformer(new DOMSource(doc)); } else if (e.getLocalName().equals("content")) { NodeList children2 = e.getChildNodes(); for (int j = 0; j < children2.getLength(); j++) { if (children2.item(j).getNodeType() == Node.ELEMENT_NODE) { content = children2.item(j); } } if (content == null) { content = children2.item(0); } } else { parser_instruction = db.newDocument(); tf.newTransformer().transform(new DOMSource(e), new DOMResult(parser_instruction)); } } } if (t == null) { t = tf.newTransformer(); } File temp = File.createTempFile("$te_", ".xml"); if (content != null && content.getNodeType() == Node.TEXT_NODE) { RandomAccessFile raf = new RandomAccessFile(temp, "rw"); raf.writeBytes(((Text) content).getTextContent()); raf.close(); } else { t.transform(new DOMSource(content), new StreamResult(temp)); } URLConnection uc = temp.toURI().toURL().openConnection(); Element result = parse(uc, parser_instruction); temp.delete(); return result; } TECore();  TECore(Engine engine, Index index, RuntimeOptions opts); TestEntry getParentTest(); String getParamsXML(List<String> params); void execute(); void reexecute_test(String testPath); int execute_test(String testName, List<String> params,
          XdmNode contextNode); void execute_suite(String suiteName, List<String> params); void execute_profile(String profileName, List<String> params,
          boolean required); XdmNode executeTemplate(TemplateEntry template, XdmNode params,
          XPathContext context); int executeTest(TestEntry test, XdmNode params, XPathContext context); void addMissingInfo(String dir, TestEntry test); synchronized void callTest(XPathContext context, String localName,
          String namespaceURI, NodeInfo params, String callId); void repeatTest(XPathContext context, String localName,
          String NamespaceURI, NodeInfo params, String callId, int count,
          int pause); NodeInfo executeXSLFunction(XPathContext context, FunctionEntry fe,
          NodeInfo params); Object callFunction(XPathContext context, String localName,
          String namespaceURI, NodeInfo params); void _continue(); void bestPractice(); void notTested(); void skipped(); void pass(); void warning(); void inheritedFailure(); void fail(); String getResult(); String getMode(); void setContextLabel(String label); String getFormHtml(); void setFormHtml(String html); Document getFormResults(); void setFormResults(Document doc); Map<String, Element> getFormParsers(); Document readLog(); PrintWriter createLog(); static File getFile(NodeList fileNodes); NodeList soap_request(Document ctlRequest, String id); static URLConnection build_soap_request(Node xml); NodeList request(Document ctlRequest, String id); URLConnection build_request(Node xml); static void writeBytes(ByteArrayOutputStream baos, byte[] bytes); Element parse(Document parse_instruction, String xsl_version); Element parse(URLConnection uc, Node instruction); Element parse(URLConnection uc, Node instruction,
          Document response_doc); Node message(String message, String id); void putLogCache(String id, Document xmlToCache); Element getLogCache(String id); Node form(Document ctlForm, String id); void setIndentLevel(int level); String getOutput(); void stopThread(); boolean isThreadComplete(); void run(); File getLogDir(); PrintStream getOut(); void setOut(PrintStream out); String getTestPath(); String getTestRunDirectory(); void setTestPath(String testPath); boolean isWeb(); void setWeb(boolean web); Object getFunctionInstance(Integer key); Object putFunctionInstance(Integer key, Object instance); Engine getEngine(); Index getIndex(); RuntimeOptions getOpts(); String getTestServletURL(); void setTestServletURL(String testServletURL); void earlHtmlReport( String outputDir ); Document findXMLResource(String name); }
TECore implements Runnable { public Element parse(Document parse_instruction, String xsl_version) throws Throwable { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); dbf.setExpandEntityReferences(false); DocumentBuilder db = dbf.newDocumentBuilder(); TransformerFactory tf = TransformerFactory.newInstance(); tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); Transformer t = null; Node content = null; Document parser_instruction = null; Element parse_element = (Element) parse_instruction .getElementsByTagNameNS(CTL_NS, "parse").item(0); NodeList children = parse_element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeType() == Node.ELEMENT_NODE) { Element e = (Element) children.item(i); if (e.getNamespaceURI().equals(XSL_NS) && e.getLocalName().equals("output")) { Document doc = db.newDocument(); Element transform = doc .createElementNS(XSL_NS, "transform"); transform.setAttribute("version", xsl_version); doc.appendChild(transform); Element output = doc.createElementNS(XSL_NS, "output"); NamedNodeMap atts = e.getAttributes(); for (int j = 0; j < atts.getLength(); j++) { Attr a = (Attr) atts.item(i); output.setAttribute(a.getName(), a.getValue()); } transform.appendChild(output); Element template = doc.createElementNS(XSL_NS, "template"); template.setAttribute("match", "node()|@*"); transform.appendChild(template); Element copy = doc.createElementNS(XSL_NS, "copy"); template.appendChild(copy); Element apply = doc.createElementNS(XSL_NS, "apply-templates"); apply.setAttribute("select", "node()|@*"); copy.appendChild(apply); t = tf.newTransformer(new DOMSource(doc)); } else if (e.getLocalName().equals("content")) { NodeList children2 = e.getChildNodes(); for (int j = 0; j < children2.getLength(); j++) { if (children2.item(j).getNodeType() == Node.ELEMENT_NODE) { content = children2.item(j); } } if (content == null) { content = children2.item(0); } } else { parser_instruction = db.newDocument(); tf.newTransformer().transform(new DOMSource(e), new DOMResult(parser_instruction)); } } } if (t == null) { t = tf.newTransformer(); } File temp = File.createTempFile("$te_", ".xml"); if (content != null && content.getNodeType() == Node.TEXT_NODE) { RandomAccessFile raf = new RandomAccessFile(temp, "rw"); raf.writeBytes(((Text) content).getTextContent()); raf.close(); } else { t.transform(new DOMSource(content), new StreamResult(temp)); } URLConnection uc = temp.toURI().toURL().openConnection(); Element result = parse(uc, parser_instruction); temp.delete(); return result; } TECore();  TECore(Engine engine, Index index, RuntimeOptions opts); TestEntry getParentTest(); String getParamsXML(List<String> params); void execute(); void reexecute_test(String testPath); int execute_test(String testName, List<String> params,
          XdmNode contextNode); void execute_suite(String suiteName, List<String> params); void execute_profile(String profileName, List<String> params,
          boolean required); XdmNode executeTemplate(TemplateEntry template, XdmNode params,
          XPathContext context); int executeTest(TestEntry test, XdmNode params, XPathContext context); void addMissingInfo(String dir, TestEntry test); synchronized void callTest(XPathContext context, String localName,
          String namespaceURI, NodeInfo params, String callId); void repeatTest(XPathContext context, String localName,
          String NamespaceURI, NodeInfo params, String callId, int count,
          int pause); NodeInfo executeXSLFunction(XPathContext context, FunctionEntry fe,
          NodeInfo params); Object callFunction(XPathContext context, String localName,
          String namespaceURI, NodeInfo params); void _continue(); void bestPractice(); void notTested(); void skipped(); void pass(); void warning(); void inheritedFailure(); void fail(); String getResult(); String getMode(); void setContextLabel(String label); String getFormHtml(); void setFormHtml(String html); Document getFormResults(); void setFormResults(Document doc); Map<String, Element> getFormParsers(); Document readLog(); PrintWriter createLog(); static File getFile(NodeList fileNodes); NodeList soap_request(Document ctlRequest, String id); static URLConnection build_soap_request(Node xml); NodeList request(Document ctlRequest, String id); URLConnection build_request(Node xml); static void writeBytes(ByteArrayOutputStream baos, byte[] bytes); Element parse(Document parse_instruction, String xsl_version); Element parse(URLConnection uc, Node instruction); Element parse(URLConnection uc, Node instruction,
          Document response_doc); Node message(String message, String id); void putLogCache(String id, Document xmlToCache); Element getLogCache(String id); Node form(Document ctlForm, String id); void setIndentLevel(int level); String getOutput(); void stopThread(); boolean isThreadComplete(); void run(); File getLogDir(); PrintStream getOut(); void setOut(PrintStream out); String getTestPath(); String getTestRunDirectory(); void setTestPath(String testPath); boolean isWeb(); void setWeb(boolean web); Object getFunctionInstance(Integer key); Object putFunctionInstance(Integer key, Object instance); Engine getEngine(); Index getIndex(); RuntimeOptions getOpts(); String getTestServletURL(); void setTestServletURL(String testServletURL); void earlHtmlReport( String outputDir ); Document findXMLResource(String name); static final String SOAP_V_1_1; static final String SOAP_V_1_2; static int testCount; static int methodCount; static String nameOfTest; public File dirPath; static String pathURL; static String assertionMsz; static String messageTest; static final int CONTINUE; static final int BEST_PRACTICE; static final int PASS; static final int NOT_TESTED; static final int SKIPPED; static final int WARNING; static final int INHERITED_FAILURE; static final int FAIL; static final String MSG_CONTINUE; static final String MSG_BEST_PRACTICE; static final String MSG_PASS; static final String MSG_NOT_TESTED; static final String MSG_SKIPPED; static final String MSG_WARNING; static final String MSG_INHERITED_FAILURE; static final String MSG_FAIL; static final int MANDATORY; static final int MANDATORY_IF_IMPLEMENTED; static final int OPTIONAL; static DocumentBuilderFactory icFactory; static DocumentBuilder icBuilder; static Document doc; static Element mainRootElement; static DocumentBuilderFactory icFactoryClause; static DocumentBuilder icBuilderClause; static Document docClause; static Element mainRootElementClause; static String TESTNAME; static int rootNo; static String Clause; static String Purpose; static ArrayList<String> rootTestName; static Document userInputs; public Boolean supportHtmlReport; final ImageHandler imageHandler; }