/** * Sets the XSLT version to set on stylesheets used internally. * * <p>Defaults to "1.0".</p> * * @throws ConfigurationException if the argument cannot be parsed * as a positive number. */ public static void setXSLTVersion(String s) { try { Number n = NumberFormat.getInstance(Locale.US).parse(s); if (n.doubleValue() < 0) { throw new ConfigurationException(s + " doesn't reperesent a" + " positive number."); } } catch (ParseException e) { throw new ConfigurationException(e); } xsltVersion = s; }
/** * Sets the XSLT version to set on stylesheets used internally. * * <p>Defaults to "1.0".</p> * * @throws ConfigurationException if the argument cannot be parsed * as a positive number. */ public static void setXSLTVersion(String s) { try { Number n = NumberFormat.getInstance(Locale.US).parse(s); if (n.doubleValue() < 0) { throw new ConfigurationException(s + " doesn't reperesent a" + " positive number."); } } catch (ParseException e) { throw new ConfigurationException(e); } xsltVersion = s; }
/** * Get the <code>DocumentBuilder</code> instance used to parse the test XML * in an XMLTestCase. * @return parser for test values * @throws ConfigurationException */ public static DocumentBuilder newTestParser() throws ConfigurationException { try { testBuilderFactory = getTestDocumentBuilderFactory(); DocumentBuilder builder = testBuilderFactory.newDocumentBuilder(); if (testEntityResolver!=null) { builder.setEntityResolver(testEntityResolver); } return builder; } catch (ParserConfigurationException ex) { throw new ConfigurationException(ex); } }
/** * Factory method * @param stylesheetSource * @throws ConfigurationException * @return */ private Transformer getTransformer(Source stylesheetSource) throws ConfigurationException { try { TransformerFactory factory = XMLUnit.getTransformerFactory(); Transformer t = stylesheetSource == null ? factory.newTransformer() : factory.newTransformer(stylesheetSource); return t; } catch (javax.xml.transform.TransformerConfigurationException ex) { throw new ConfigurationException(ex); } }
/** * Get the <code>DocumentBuilder</code> instance used to parse the control * XML in an XMLTestCase. * @return parser for control values * @throws ConfigurationException */ public static DocumentBuilder newControlParser() throws ConfigurationException { try { controlBuilderFactory = getControlDocumentBuilderFactory(); DocumentBuilder builder = controlBuilderFactory.newDocumentBuilder(); if (controlEntityResolver!=null) { builder.setEntityResolver(controlEntityResolver); } return builder; } catch (ParserConfigurationException ex) { throw new ConfigurationException(ex); } }
/** * Get the <code>DocumentBuilder</code> instance used to parse the test XML * in an XMLTestCase. * @return parser for test values * @throws ConfigurationException */ public static DocumentBuilder newTestParser() throws ConfigurationException { try { testBuilderFactory = getTestDocumentBuilderFactory(); DocumentBuilder builder = testBuilderFactory.newDocumentBuilder(); if (testEntityResolver!=null) { builder.setEntityResolver(testEntityResolver); } return builder; } catch (ParserConfigurationException ex) { throw new ConfigurationException(ex); } }
public Jaxp13XpathEngine() throws ConfigurationException { try { XPathFactory f = null; if (XMLUnit.getXPathFactory() != null) { f = (XPathFactory) Class.forName(XMLUnit.getXPathFactory()) .newInstance(); } else { f = XPathFactory.newInstance(); } xpath = f.newXPath(); } catch (Exception ex) { throw new ConfigurationException(ex); } }
/** * Get the <code>DocumentBuilder</code> instance used to parse the control * XML in an XMLTestCase. * @return parser for control values * @throws ConfigurationException */ public static DocumentBuilder newControlParser() throws ConfigurationException { try { controlBuilderFactory = getControlDocumentBuilderFactory(); DocumentBuilder builder = controlBuilderFactory.newDocumentBuilder(); if (controlEntityResolver!=null) { builder.setEntityResolver(controlEntityResolver); } return builder; } catch (ParserConfigurationException ex) { throw new ConfigurationException(ex); } }
/** * Baseline constructor: called by all others * * @param inputSource * @param systemId * @param usingDoctypeReader * @throws SAXException * @throws ConfigurationException if validation could not be turned on */ protected Validator(InputSource inputSource, String systemId, boolean usingDoctypeReader) throws SAXException, ConfigurationException { isValid = null; messages = new StringBuffer(); SAXParserFactory factory = XMLUnit.getSAXParserFactory(); factory.setValidating(true); try { parser = factory.newSAXParser(); } catch (ParserConfigurationException ex) { throw new ConfigurationException(ex); } this.validationInputSource = inputSource; if (systemId != null) { validationInputSource.setSystemId(systemId); } this.usingDoctypeReader = usingDoctypeReader; }
public Jaxp13XpathEngine() throws ConfigurationException { try { JAXPXPathEngine e = null; if (XMLUnit.getXPathFactory() != null) { e = new JAXPXPathEngine((XPathFactory) Class .forName(XMLUnit.getXPathFactory()) .newInstance()); } else { e = new JAXPXPathEngine(); } engine = e; } catch (org.xmlunit.ConfigurationException ex) { throw new ConfigurationException(ex.getCause()); } catch (Exception ex) { throw new ConfigurationException(ex); } }
transformer.transform(new DOMSource(document), result); } catch (javax.xml.transform.TransformerConfigurationException ex) { throw new ConfigurationException(ex);
transformer.transform(new DOMSource(document), result); } catch (javax.xml.transform.TransformerConfigurationException ex) { throw new ConfigurationException(ex);
throw new ConfigurationException(e.getCause()); } catch (org.xmlunit.XMLUnitException e) { throw new XMLUnitRuntimeException(e.getMessage(), e.getCause());
static <R> R withExceptionHandling(Trans<R> trans) throws TransformerException { try { return trans.transform(); } catch (org.xmlunit.ConfigurationException ex) { throw new ConfigurationException(ex.getMessage(), ex.getCause()); } catch (XMLUnitException ex) { Throwable cause = ex.getCause(); if (cause instanceof TransformerException) { throw (TransformerException) cause; } throw new XMLUnitRuntimeException(ex.getMessage(), cause); } }