This is an automated email from the ASF dual-hosted git repository.

ppkarwasz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/commons-xml.git

commit 2f07b4984a4a9fb71e5e0d4b9541066c3972002b
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Thu Apr 23 23:09:51 2026 +0200

    feat: add provider for Woodstox
---
 pom.xml                                            |  4 +-
 .../xml/factory/internal/ProviderRegistry.java     |  2 +-
 .../xml/factory/internal/WoodstoxProvider.java     | 47 ++++++++++++++++++++++
 3 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index 55eb204..560aa29 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,7 +108,6 @@
               </additionalClasspathDependencies>
             </configuration>
           </execution>
-          <!--
           <execution>
             <id>test-woodstox</id>
             <goals><goal>test</goal></goals>
@@ -120,9 +119,10 @@
                   <artifactId>woodstox-core</artifactId>
                   <version>${commons.woodstox.version}</version>
                 </dependency>
-              </additionalClassPathDependencies>
+              </additionalClasspathDependencies>
             </configuration>
           </execution>
+          <!--
           <execution>
             <id>test-saxon</id>
             <goals><goal>test</goal></goals>
diff --git 
a/src/main/java/org/apache/commons/xml/factory/internal/ProviderRegistry.java 
b/src/main/java/org/apache/commons/xml/factory/internal/ProviderRegistry.java
index 636eaaf..5a7c54f 100644
--- 
a/src/main/java/org/apache/commons/xml/factory/internal/ProviderRegistry.java
+++ 
b/src/main/java/org/apache/commons/xml/factory/internal/ProviderRegistry.java
@@ -98,7 +98,7 @@ private XmlProvider lookup(final Class<?> factoryClass) {
     }
 
     private static List<XmlProvider> bundledProviders() {
-        return Arrays.asList(new StockJdkProvider(), new XercesProvider());
+        return Arrays.asList(new StockJdkProvider(), new XercesProvider(), new 
WoodstoxProvider());
     }
 
     private static Iterable<XmlProvider> serviceLoaderProviders() {
diff --git 
a/src/main/java/org/apache/commons/xml/factory/internal/WoodstoxProvider.java 
b/src/main/java/org/apache/commons/xml/factory/internal/WoodstoxProvider.java
new file mode 100644
index 0000000..24148f2
--- /dev/null
+++ 
b/src/main/java/org/apache/commons/xml/factory/internal/WoodstoxProvider.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.xml.factory.internal;
+
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.commons.xml.factory.spi.XmlProvider;
+
+/**
+ * {@link XmlProvider} for the FasterXML Woodstox StAX implementation ({@code 
com.ctc.wstx:woodstox-core}).
+ *
+ * <p>Woodstox is a StAX-only library, so this provider implements only {@link 
#configure(XMLInputFactory)}.</p>
+ *
+ * <p>Hardening uses the JAXP-spec StAX properties.</p>
+ *
+ * <p>Must be declared {@code public} so {@link java.util.ServiceLoader} can 
load it from {@code META-INF/services/}.</p>
+ */
+public final class WoodstoxProvider extends AbstractXmlProvider {
+
+    /**
+     * Default constructor; invoked by {@link java.util.ServiceLoader} and the 
registry.
+     */
+    public WoodstoxProvider() {
+        super("com.ctc.wstx.stax.WstxInputFactory");
+    }
+
+    @Override
+    public XMLInputFactory configure(final XMLInputFactory factory) {
+        setProperty(factory, XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
+        setProperty(factory, XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
+        return factory;
+    }
+}

Reply via email to