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 2302fc4c give the builtin xs:IDREFS type its minLength=1 list facet
(#142)
2302fc4c is described below
commit 2302fc4cbcfe0832930ce579d846537ba298f1dd
Author: aizu-m <[email protected]>
AuthorDate: Sun Oct 25 15:36:22 2026 +0530
give the builtin xs:IDREFS type its minLength=1 list facet (#142)
---
.../impl/schema/BuiltinSchemaTypeSystem.java | 7 +-
.../impl/schema/XQuerySchemaTypeSystem.java | 7 +-
.../misc/checkin/IdrefsMinLengthValidateTest.java | 84 ++++++++++++++++++++++
3 files changed, 96 insertions(+), 2 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 de16f860..f1bcf1bb 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/BuiltinSchemaTypeSystem.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/BuiltinSchemaTypeSystem.java
@@ -866,7 +866,6 @@ public class BuiltinSchemaTypeSystem extends
SchemaTypeLoaderBase implements Sch
case SchemaType.BTC_LANGUAGE:
case SchemaType.BTC_ID:
case SchemaType.BTC_IDREF:
- case SchemaType.BTC_IDREFS:
case SchemaType.BTC_ENTITY:
case SchemaType.BTC_NMTOKEN:
facets = FACETS_WS_COLLAPSE;
@@ -874,6 +873,12 @@ public class BuiltinSchemaTypeSystem extends
SchemaTypeLoaderBase implements Sch
wsr = SchemaType.WS_COLLAPSE;
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;
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 e307c827..51d58e13 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/XQuerySchemaTypeSystem.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/XQuerySchemaTypeSystem.java
@@ -888,7 +888,6 @@ public class XQuerySchemaTypeSystem extends
SchemaTypeLoaderBase implements
case SchemaType.BTC_LANGUAGE:
case SchemaType.BTC_ID:
case SchemaType.BTC_IDREF:
- case SchemaType.BTC_IDREFS:
case SchemaType.BTC_ENTITY:
case SchemaType.BTC_NMTOKEN:
facets = FACETS_WS_COLLAPSE;
@@ -896,6 +895,12 @@ public class XQuerySchemaTypeSystem extends
SchemaTypeLoaderBase implements
wsr = SchemaType.WS_COLLAPSE;
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;
diff --git a/src/test/java/misc/checkin/IdrefsMinLengthValidateTest.java
b/src/test/java/misc/checkin/IdrefsMinLengthValidateTest.java
new file mode 100644
index 00000000..5984895e
--- /dev/null
+++ b/src/test/java/misc/checkin/IdrefsMinLengthValidateTest.java
@@ -0,0 +1,84 @@
+/* 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.SchemaTypeLoader;
+import org.apache.xmlbeans.SimpleValue;
+import org.apache.xmlbeans.XmlBeans;
+import org.apache.xmlbeans.XmlIDREFS;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class IdrefsMinLengthValidateTest {
+
+ private static final String XSD =
+ "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'
xmlns:t='urn:t' " +
+ "targetNamespace='urn:t' elementFormDefault='qualified'>" +
+ " <xs:element name='root'>" +
+ " <xs:complexType>" +
+ " <xs:sequence>" +
+ " <xs:element name='id' type='xs:ID' minOccurs='0'
maxOccurs='unbounded'/>" +
+ " <xs:element name='refs' type='xs:IDREFS' minOccurs='0'/>" +
+ " </xs:sequence>" +
+ " <xs:attribute name='refs' type='xs:IDREFS'/>" +
+ " </xs:complexType>" +
+ " </xs:element>" +
+ "</xs:schema>";
+
+ private static SchemaTypeLoader loader;
+
+ @BeforeAll
+ static void compileSchema() throws Exception {
+ loader = XmlBeans.loadXsd(new
XmlObject[]{SchemaDocument.Factory.parse(XSD)});
+ }
+
+ private static boolean validates(String body) throws Exception {
+ XmlObject doc = loader.parse(body, null, null);
+ return doc.validate();
+ }
+
+ @Test
+ void idrefsHasBuiltinMinLength() {
+ // xs:IDREFS, like xs:ENTITIES and xs:NMTOKENS, is defined with
minLength=1
+ XmlObject minLength =
XmlIDREFS.type.getFacet(SchemaType.FACET_MIN_LENGTH);
+ assertNotNull(minLength);
+ assertEquals(1, ((SimpleValue) minLength).getIntValue());
+ assertEquals(SchemaType.WS_COLLAPSE,
XmlIDREFS.type.getWhiteSpaceRule());
+ }
+
+ @Test
+ void emptyIdrefsIsReported() throws Exception {
+ assertFalse(validates("<t:root xmlns:t='urn:t'><t:refs/></t:root>"));
+ assertFalse(validates("<t:root xmlns:t='urn:t'><t:refs>
</t:refs></t:root>"));
+ assertFalse(validates("<t:root xmlns:t='urn:t' refs=''/>"));
+ assertFalse(validates("<t:root xmlns:t='urn:t' refs=' '/>"));
+ }
+
+ @Test
+ void nonEmptyIdrefsStillValidate() throws Exception {
+ assertTrue(validates("<t:root
xmlns:t='urn:t'><t:id>a</t:id><t:id>b</t:id><t:refs> a b </t:refs></t:root>"));
+ assertTrue(validates("<t:root xmlns:t='urn:t'
refs='a'><t:id>a</t:id></t:root>"));
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]