You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by jb...@apache.org on 2009/06/03 21:47:12 UTC
svn commit: r781522 -
/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jbi/jaxp/SourceTransformer.java
Author: jbonofre
Date: Wed Jun 3 19:47:12 2009
New Revision: 781522
URL: http://svn.apache.org/viewvc?rev=781522&view=rev
Log:
SM-1613: Add a property to validate or not using external DTD (by default, it's true, validating).
Modified:
servicemix/utils/trunk/src/main/java/org/apache/servicemix/jbi/jaxp/SourceTransformer.java
Modified: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jbi/jaxp/SourceTransformer.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jbi/jaxp/SourceTransformer.java?rev=781522&r1=781521&r2=781522&view=diff
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jbi/jaxp/SourceTransformer.java (original)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jbi/jaxp/SourceTransformer.java Wed Jun 3 19:47:12 2009
@@ -58,6 +58,7 @@
public class SourceTransformer {
public static final String DEFAULT_CHARSET_PROPERTY = "org.apache.servicemix.default.charset";
+ public static final String DEFAULT_VALIDATING_DTD_PROPERTY = "org.apache.servicemix.default.validating-dtd";
/*
* When converting a DOM tree to a SAXSource, we try to use Xalan internal
@@ -76,6 +77,7 @@
}
private static String defaultCharset = System.getProperty(DEFAULT_CHARSET_PROPERTY, "UTF-8");
+ private static boolean defaultValidatingDtd = (new Boolean(System.getProperty(DEFAULT_VALIDATING_DTD_PROPERTY, "true"))).booleanValue();
private DocumentBuilderFactory documentBuilderFactory;
@@ -95,6 +97,14 @@
public static void setDefaultCharset(String defaultCharset) {
SourceTransformer.defaultCharset = defaultCharset;
}
+
+ public static boolean getDefaultValidatingDtd() {
+ return defaultValidatingDtd;
+ }
+
+ public static void setDefaultValidatingDtd(boolean defaultValidatingDtd) {
+ SourceTransformer.defaultValidatingDtd = defaultValidatingDtd;
+ }
/**
* Converts the given input Source into the required result, using the default charset
@@ -278,6 +288,8 @@
try {
Constructor cns = DOM_2_SAX_CLASS.getConstructor(new Class[] {Node.class });
XMLReader converter = (XMLReader) cns.newInstance(new Object[] {source.getNode() });
+ converter.setFeature("http://xml.org/sax/features/validation", defaultValidatingDtd);
+ converter.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", defaultValidatingDtd);
return new SAXSource(converter, new InputSource());
} catch (Exception e) {
throw new TransformerException(e);
@@ -467,6 +479,7 @@
factory.setNamespaceAware(true);
factory.setIgnoringElementContentWhitespace(true);
factory.setIgnoringComments(true);
+ factory.setValidating(defaultValidatingDtd);
return factory;
}