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

pjfanning pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi-xmlbeans.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 1aab80d2 give the builtin xs:NMTOKENS and xs:ENTITIES types the 
collapse whitespace rule (#148)
1aab80d2 is described below

commit 1aab80d240b2bcb8c453dfd97d94e382c383a91b
Author: PJ Fanning <[email protected]>
AuthorDate: Sun Oct 25 10:25:36 2026 +0000

    give the builtin xs:NMTOKENS and xs:ENTITIES types the collapse whitespace 
rule (#148)
    
    BuiltinSchemaTypeSystem.fillInType (and its copy in XQuerySchemaTypeSystem)
    gave xs:ENTITIES and xs:NMTOKENS WS_UNSPECIFIED, although their
    FACETS_BUILTIN_LIST whiteSpace facet says collapse, as XML Schema Part 2
    requires for list types, and xs:IDREFS already uses WS_COLLAPSE. With the
    base rule unspecified, StscSimpleTypeResolver accepted a
    <xs:whiteSpace value='preserve'/> restriction of them, which it rejects
    for xs:IDREFS. Fold the three list types into one case.
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 .../impl/schema/BuiltinSchemaTypeSystem.java       |  7 +--
 .../impl/schema/XQuerySchemaTypeSystem.java        |  7 +--
 .../misc/checkin/BuiltinListWhiteSpaceTest.java    | 63 ++++++++++++++++++++++
 3 files changed, 65 insertions(+), 12 deletions(-)

diff --git 
a/src/main/java/org/apache/xmlbeans/impl/schema/BuiltinSchemaTypeSystem.java 
b/src/main/java/org/apache/xmlbeans/impl/schema/BuiltinSchemaTypeSystem.java
index f1bcf1bb..f5ce443e 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/BuiltinSchemaTypeSystem.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/BuiltinSchemaTypeSystem.java
@@ -874,16 +874,11 @@ public class BuiltinSchemaTypeSystem extends 
SchemaTypeLoaderBase implements Sch
                 break;
 
             case SchemaType.BTC_IDREFS:
-                facets = FACETS_BUILTIN_LIST;
-                fixedf = FIXED_FACETS_NONE;
-                wsr = SchemaType.WS_COLLAPSE;
-                break;
-
             case SchemaType.BTC_ENTITIES:
             case SchemaType.BTC_NMTOKENS:
                 facets = FACETS_BUILTIN_LIST;
                 fixedf = FIXED_FACETS_NONE;
-                wsr = SchemaType.WS_UNSPECIFIED;
+                wsr = SchemaType.WS_COLLAPSE;
                 break;
 
             default:
diff --git 
a/src/main/java/org/apache/xmlbeans/impl/schema/XQuerySchemaTypeSystem.java 
b/src/main/java/org/apache/xmlbeans/impl/schema/XQuerySchemaTypeSystem.java
index 51d58e13..e2ffd9da 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/XQuerySchemaTypeSystem.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/XQuerySchemaTypeSystem.java
@@ -896,16 +896,11 @@ public class XQuerySchemaTypeSystem extends 
SchemaTypeLoaderBase implements
                 break;
 
             case SchemaType.BTC_IDREFS:
-                facets = FACETS_BUILTIN_LIST;
-                fixedf = FIXED_FACETS_NONE;
-                wsr = SchemaType.WS_COLLAPSE;
-                break;
-
             case SchemaType.BTC_ENTITIES:
             case SchemaType.BTC_NMTOKENS:
                 facets = FACETS_BUILTIN_LIST;
                 fixedf = FIXED_FACETS_NONE;
-                wsr = SchemaType.WS_UNSPECIFIED;
+                wsr = SchemaType.WS_COLLAPSE;
                 break;
 
             case BTC_DAY_TIME_DURATION:
diff --git a/src/test/java/misc/checkin/BuiltinListWhiteSpaceTest.java 
b/src/test/java/misc/checkin/BuiltinListWhiteSpaceTest.java
new file mode 100644
index 00000000..4280fbc1
--- /dev/null
+++ b/src/test/java/misc/checkin/BuiltinListWhiteSpaceTest.java
@@ -0,0 +1,63 @@
+/*   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
+ *
+ *       http://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 misc.checkin;
+
+import org.apache.xmlbeans.SchemaType;
+import org.apache.xmlbeans.XmlBeans;
+import org.apache.xmlbeans.XmlENTITIES;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlIDREFS;
+import org.apache.xmlbeans.XmlNMTOKENS;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.impl.schema.XQuerySchemaTypeSystem;
+import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+public class BuiltinListWhiteSpaceTest {
+
+    private static void load(String types) throws Exception {
+        String xsd =
+            "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' 
targetNamespace='urn:t'>" +
+            types +
+            "</xs:schema>";
+        XmlBeans.loadXsd(new XmlObject[]{SchemaDocument.Factory.parse(xsd)});
+    }
+
+    @Test
+    void builtinListsCollapse() {
+        // xs:NMTOKENS, xs:ENTITIES and xs:IDREFS are lists, whose whiteSpace 
is collapse
+        assertEquals(SchemaType.WS_COLLAPSE, 
XmlNMTOKENS.type.getWhiteSpaceRule());
+        assertEquals(SchemaType.WS_COLLAPSE, 
XmlENTITIES.type.getWhiteSpaceRule());
+        assertEquals(SchemaType.WS_COLLAPSE, 
XmlIDREFS.type.getWhiteSpaceRule());
+        assertEquals(SchemaType.WS_COLLAPSE, 
XQuerySchemaTypeSystem.ST_NMTOKENS.getWhiteSpaceRule());
+        assertEquals(SchemaType.WS_COLLAPSE, 
XQuerySchemaTypeSystem.ST_ENTITIES.getWhiteSpaceRule());
+        assertEquals(SchemaType.WS_COLLAPSE, 
XQuerySchemaTypeSystem.ST_IDREFS.getWhiteSpaceRule());
+    }
+
+    @Test
+    void preserveRestrictionOfNmtokensIsRejected() {
+        assertThrows(XmlException.class, () -> load(
+            "<xs:simpleType name='loose'>" +
+            "  <xs:restriction base='xs:NMTOKENS'>" +
+            "    <xs:whiteSpace value='preserve'/>" +
+            "  </xs:restriction>" +
+            "</xs:simpleType>"));
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to