8351969: Add Public Identifiers to the JDK built-in Catalog

Reviewed-by: rriggs, lancea, iris, naoto
This commit is contained in:
Joe Wang 2025-03-19 16:37:05 +00:00
parent c7f333888b
commit 8e999b83a4
4 changed files with 143 additions and 234 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -38,9 +38,10 @@
<system systemId="http://java.sun.com/dtd/preferences.dtd" uri="preferences.dtd"/>
<system systemId="http://java.sun.com/dtd/properties.dtd" uri="properties.dtd"/>
</group>
<!-- W3C DTDs -->
<group id="xhtml11" prefer = "system" xml:base = "w3c/dtd/xhtml11/">
<public publicId="-//W3C//DTD XHTML 1.1//EN" uri="xhtml11.dtd"/>
<system systemId="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" uri="xhtml11.dtd"/>
<systemSuffix systemIdSuffix="xhtml-attribs-1.mod" uri="xhtml-attribs-1.mod"/>
<systemSuffix systemIdSuffix="xhtml-base-1.mod" uri="xhtml-base-1.mod"/>
@ -81,8 +82,11 @@
<systemSuffix systemIdSuffix="xhtml-text-1.mod" uri="xhtml-text-1.mod"/>
<systemSuffix systemIdSuffix="xhtml11-model-1.mod" uri="xhtml11-model-1.mod"/>
</group>
<group id="xhtml1" prefer = "system" xml:base = "w3c/dtd/xhtml10/">
<public publicId="-//W3C//DTD XHTML 1.0 Strict//EN" uri="xhtml1-strict.dtd"/>
<public publicId="-//W3C//DTD XHTML 1.0 Transitional//EN" uri="xhtml1-transitional.dtd"/>
<public publicId="-//W3C//DTD XHTML 1.0 Frameset//EN" uri="xhtml1-frameset.dtd"/>
<systemSuffix systemIdSuffix="xhtml1-strict.dtd" uri="xhtml1-strict.dtd"/>
<systemSuffix systemIdSuffix="xhtml1-transitional.dtd" uri="xhtml1-transitional.dtd"/>
<systemSuffix systemIdSuffix="xhtml1-frameset.dtd" uri="xhtml1-frameset.dtd"/>
@ -97,11 +101,12 @@
<public publicId="datatypes" uri="datatypes.dtd"/>
<public publicId="-//W3C//DTD XMLSCHEMA 200102//EN" uri="XMLSchema.dtd"/>
</group>
<group id="xmlspec" prefer = "system" xml:base = "w3c/dtd/">
<public publicId="-//W3C//DTD Specification V2.10//EN" uri="xmlspec2_10/xmlspec.dtd"/>
<system systemId="http://www.w3.org/2002/xmlspec/dtd/2.10/xmlspec.dtd" uri="xmlspec2_10/xmlspec.dtd"/>
</group>
<!-- W3C XSDs -->
<group id="w3cxsd" prefer = "system" xml:base = "w3c/xsd/">
<systemSuffix systemIdSuffix="XMLSchema.xsd" uri="schema10/XMLSchema.xsd"/>

View File

@ -1,21 +1,23 @@
<!-- DTD for XML Schema Definition Language Part 1: Structures
Public Identifier: "-//W3C//DTD XSD 1.1//EN"
Official Location: http://www.w3.org/2009/XMLSchema/XMLSchema.dtd -->
<!-- Id: structures.dtd,v 1.1 2003/08/28 13:30:52 ht Exp -->
<!-- DTD for XML Schemas: Part 1: Structures
Public Identifier: "-//W3C//DTD XMLSCHEMA 200102//EN"
Official Location: http://www.w3.org/2001/XMLSchema.dtd -->
<!-- $Id: XMLSchema.dtd,v 1.31 2001/10/24 15:50:16 ht Exp $ -->
<!-- Note this DTD is NOT normative, or even definitive. --> <!--d-->
<!-- prose copy in the structures REC is the definitive version --> <!--d-->
<!-- (which shouldn't differ from this one except for this --> <!--d-->
<!-- comment and entity expansions, but just in case) --> <!--d-->
<!-- With the exception of cases with multiple namespace
prefixes for the XSD namespace, any XML document which is
prefixes for the XML Schema namespace, any XML document which is
not valid per this DTD given redefinitions in its internal subset of the
'p' and 's' parameter entities below appropriate to its namespace
declaration of the XSD namespace is almost certainly not
a valid schema document. -->
declaration of the XML Schema namespace is almost certainly not
a valid schema. -->
<!-- See below (at the bottom of this document) for information about
the revision and namespace-versioning policy governing this DTD. -->
<!-- The simpleType element and its constituent parts
are defined in XML Schema Definition Language Part 2: Datatypes -->
<!ENTITY % xs-datatypes PUBLIC '-//W3C//DTD XSD 1.1 Datatypes//EN' 'datatypes.dtd' >
are defined in XML Schema: Part 2: Datatypes -->
<!ENTITY % xs-datatypes PUBLIC 'datatypes' 'datatypes.dtd' >
<!ENTITY % p 'xs:'> <!-- can be overridden in the internal subset of a
<!ENTITY % p 'xs:'> <!-- can be overriden in the internal subset of a
schema document to establish a different
namespace prefix -->
<!ENTITY % s ':xs'> <!-- if %p is defined (e.g. as foo:) then you must
@ -25,14 +27,11 @@
<!-- Define all the element names, with optional prefix -->
<!ENTITY % schema "%p;schema">
<!ENTITY % defaultOpenContent "%p;defaultOpenContent">
<!ENTITY % complexType "%p;complexType">
<!ENTITY % complexContent "%p;complexContent">
<!ENTITY % openContent "%p;openContent">
<!ENTITY % simpleContent "%p;simpleContent">
<!ENTITY % extension "%p;extension">
<!ENTITY % element "%p;element">
<!ENTITY % alternative "%p;alternative">
<!ENTITY % unique "%p;unique">
<!ENTITY % key "%p;key">
<!ENTITY % keyref "%p;keyref">
@ -49,10 +48,7 @@
<!ENTITY % include "%p;include">
<!ENTITY % import "%p;import">
<!ENTITY % redefine "%p;redefine">
<!ENTITY % override "%p;override">
<!ENTITY % notation "%p;notation">
<!ENTITY % assert "%p;assert">
<!-- annotation elements -->
<!ENTITY % annotation "%p;annotation">
@ -61,14 +57,11 @@
<!-- Customisation entities for the ATTLIST of each element type.
Define one of these if your schema takes advantage of the
anyAttribute='##other' in the
schema for schema documents -->
anyAttribute='##other' in the schema for schemas -->
<!ENTITY % schemaAttrs ''>
<!ENTITY % defaultOpenContentAttrs ''>
<!ENTITY % complexTypeAttrs ''>
<!ENTITY % complexContentAttrs ''>
<!ENTITY % openContentAttrs ''>
<!ENTITY % simpleContentAttrs ''>
<!ENTITY % extensionAttrs ''>
<!ENTITY % elementAttrs ''>
@ -85,12 +78,9 @@
<!ENTITY % keyrefAttrs ''>
<!ENTITY % selectorAttrs ''>
<!ENTITY % fieldAttrs ''>
<!ENTITY % assertAttrs ''>
<!ENTITY % includeAttrs ''>
<!ENTITY % importAttrs ''>
<!ENTITY % redefineAttrs ''>
<!ENTITY % overrideAttrs ''>
<!ENTITY % notationAttrs ''>
<!ENTITY % annotationAttrs ''>
<!ENTITY % appinfoAttrs ''>
@ -102,7 +92,6 @@
<!-- #all or space-separated list drawn from
derivationChoice + 'substitution' -->
<!ENTITY % composition '%include; | %import; | %override; | %redefine;'>
<!ENTITY % mgs '%all; | %choice; | %sequence;'>
<!ENTITY % cs '%choice; | %sequence;'>
<!ENTITY % formValues '(qualified|unqualified)'>
@ -110,20 +99,16 @@
<!ENTITY % attrDecls '((%attribute;| %attributeGroup;)*,(%anyAttribute;)?)'>
<!ENTITY % assertions '(%assert;)*'>
<!ENTITY % particleAndAttrs '(%openContent;?, (%mgs; | %group;)?,
%attrDecls;, %assertions;)'>
<!ENTITY % particleAndAttrs '((%mgs; | %group;)?, %attrDecls;)'>
<!-- This is used in part2 -->
<!ENTITY % restriction1 '(%openContent;?, (%mgs; | %group;)?)'>
<!ENTITY % restriction1 '((%mgs; | %group;)?)'>
%xs-datatypes;
<!-- the duplication below is to produce an unambiguous content model
which allows annotation everywhere -->
<!ELEMENT %schema; ((%composition; | %annotation;)*,
(%defaultOpenContent;, (%annotation;)*)?,
<!ELEMENT %schema; ((%include; | %import; | %redefine; | %annotation;)*,
((%simpleType; | %complexType;
| %element; | %attribute;
| %attributeGroup; | %group;
@ -139,28 +124,18 @@
id ID #IMPLIED
elementFormDefault %formValues; 'unqualified'
attributeFormDefault %formValues; 'unqualified'
defaultAttributes CDATA #IMPLIED
xpathDefaultNamespace CDATA '##local'
xml:lang CDATA #IMPLIED
%schemaAttrs;>
<!-- Note the xmlns declaration is NOT in the
schema for schema documents,
<!-- Note the xmlns declaration is NOT in the Schema for Schemas,
because at the Infoset level where schemas operate,
xmlns(:prefix) is NOT an attribute! -->
<!-- The declaration of xmlns is a convenience for schema authors -->
<!-- The id attribute here and below is for use in external references
from non-schemas using simple fragment identifiers.
It is NOT used for schema-to-schema reference, internal or
external. -->
<!ELEMENT %defaultOpenContent; ((%annotation;)?, %any;)>
<!ATTLIST %defaultOpenContent;
appliesToEmpty (true|false) 'false'
mode (interleave|suffix) 'interleave'
id ID #IMPLIED
%defaultOpenContentAttrs;>
<!-- a type is a named content type specification which allows attribute
declarations-->
<!-- -->
@ -170,17 +145,17 @@
%particleAndAttrs;))>
<!ATTLIST %complexType;
name %NCName; #IMPLIED
id ID #IMPLIED
abstract %boolean; #IMPLIED
final %complexDerivationSet; #IMPLIED
block %complexDerivationSet; #IMPLIED
mixed (true|false) 'false'
defaultAttributesApply %boolean; 'true'
name %NCName; #IMPLIED
id ID #IMPLIED
abstract %boolean; #IMPLIED
final %complexDerivationSet; #IMPLIED
block %complexDerivationSet; #IMPLIED
mixed (true|false) 'false'
%complexTypeAttrs;>
<!-- particleAndAttrs is shorthand for a root type -->
<!-- mixed is disallowed if simpleContent, overridden if complexContent has one too. -->
<!-- mixed is disallowed if simpleContent, overriden if complexContent
has one too. -->
<!-- If anyAttribute appears in one or more referenced attributeGroups
and/or explicitly, the intersection of the permissions is used -->
@ -191,12 +166,6 @@
id ID #IMPLIED
%complexContentAttrs;>
<!ELEMENT %openContent; ((%annotation;)?, (%any;)?)>
<!ATTLIST %openContent;
mode (none|interleave|suffix) 'interleave'
id ID #IMPLIED
%openContentAttrs;>
<!-- restriction should use the branch defined above, not the simple
one from part2; extension should use the full model -->
@ -205,14 +174,13 @@
id ID #IMPLIED
%simpleContentAttrs;>
<!-- restriction should use the simple branch from part2, not the
<!-- restriction should use the simple branch from part2, not the
one defined above; extension should have no particle -->
<!ELEMENT %extension; ((%annotation;)?, (%particleAndAttrs;))>
<!ATTLIST %extension;
base %QName; #REQUIRED
id ID #IMPLIED
base %QName; #REQUIRED
id ID #IMPLIED
%extensionAttrs;>
<!-- an element is declared by either:
@ -220,7 +188,6 @@
or a ref to an existing element declaration -->
<!ELEMENT %element; ((%annotation;)?, (%complexType;| %simpleType;)?,
(%alternative;)*,
(%unique; | %key; | %keyref;)*)>
<!-- simpleType or complexType only if no type|ref attribute -->
<!-- ref not allowed at top level -->
@ -239,25 +206,15 @@
default CDATA #IMPLIED
fixed CDATA #IMPLIED
form %formValues; #IMPLIED
targetNamespace %URIref; #IMPLIED
%elementAttrs;>
<!-- type and ref are mutually exclusive.
name and ref are mutually exclusive, one is required -->
<!-- In the absence of type AND ref, type defaults to type of
substitutionGroup, if any, else xs:anyType, i.e. unconstrained -->
substitutionGroup, if any, else the ur-type, i.e. unconstrained -->
<!-- default and fixed are mutually exclusive -->
<!ELEMENT %alternative; ((%annotation;)?,
(%simpleType; | %complexType;)?) >
<!ATTLIST %alternative;
test CDATA #IMPLIED
type %QName; #IMPLIED
xpathDefaultNamespace CDATA #IMPLIED
id ID #IMPLIED >
<!ELEMENT %group; ((%annotation;)?,(%mgs;)?)>
<!ATTLIST %group;
<!ATTLIST %group;
name %NCName; #IMPLIED
ref %QName; #IMPLIED
minOccurs %nonNegativeInteger; #IMPLIED
@ -265,10 +222,10 @@
id ID #IMPLIED
%groupAttrs;>
<!ELEMENT %all; ((%annotation;)?, (%element;| %group;| %any;)*)>
<!ELEMENT %all; ((%annotation;)?, (%element;)*)>
<!ATTLIST %all;
minOccurs (0 | 1) #IMPLIED
maxOccurs (0 | 1) #IMPLIED
minOccurs (1) #IMPLIED
maxOccurs (1) #IMPLIED
id ID #IMPLIED
%allAttrs;>
@ -289,12 +246,15 @@
<!-- an anonymous grouping in a model, or
a top-level named group definition, or a reference to same -->
<!-- Note that if order is 'all', group is not allowed inside.
If order is 'all' THIS group must be alone (or referenced alone) at
the top level of a content model -->
<!-- If order is 'all', minOccurs==maxOccurs==1 on element/any inside -->
<!-- Should allow minOccurs=0 inside order='all' . . . -->
<!ELEMENT %any; (%annotation;)?>
<!ATTLIST %any;
namespace CDATA #IMPLIED
notNamespace CDATA #IMPLIED
notQName CDATA ''
namespace CDATA '##any'
processContents (skip|lax|strict) 'strict'
minOccurs %nonNegativeInteger; '1'
maxOccurs CDATA '1'
@ -315,39 +275,26 @@
##targetNamespace ##local may appear in the above list,
with the obvious meaning -->
<!-- notNamespace is interpreted as follows:
##local - - any unqualified non-conflicting WFXML/attribute
one or - - any non-conflicting WFXML from
more URI the listed namespaces
references
##targetNamespace ##local may appear in the above list,
with the obvious meaning -->
<!ELEMENT %anyAttribute; (%annotation;)?>
<!ATTLIST %anyAttribute;
namespace CDATA #IMPLIED
notNamespace CDATA #IMPLIED
notQName CDATA ''
namespace CDATA '##any'
processContents (skip|lax|strict) 'strict'
id ID #IMPLIED
%anyAttributeAttrs;>
<!-- namespace and notNamespace are interpreted as for 'any' above -->
<!-- namespace is interpreted as for 'any' above -->
<!-- simpleType only if no type|ref attribute -->
<!-- ref not allowed at top level, name iff at top level -->
<!ELEMENT %attribute; ((%annotation;)?, (%simpleType;)?)>
<!ATTLIST %attribute;
name %NCName; #IMPLIED
id ID #IMPLIED
ref %QName; #IMPLIED
type %QName; #IMPLIED
use (prohibited|optional|required) #IMPLIED
default CDATA #IMPLIED
fixed CDATA #IMPLIED
form %formValues; #IMPLIED
targetNamespace %URIref; #IMPLIED
inheritable %boolean; #IMPLIED
name %NCName; #IMPLIED
id ID #IMPLIED
ref %QName; #IMPLIED
type %QName; #IMPLIED
use (prohibited|optional|required) #IMPLIED
default CDATA #IMPLIED
fixed CDATA #IMPLIED
form %formValues; #IMPLIED
%attributeAttrs;>
<!-- type and ref are mutually exclusive.
name and ref are mutually exclusive, one is required -->
@ -371,48 +318,34 @@
<!-- better reference mechanisms -->
<!ELEMENT %unique; ((%annotation;)?, %selector;, (%field;)+)>
<!ATTLIST %unique;
name %NCName; #IMPLIED
ref %QName; #IMPLIED
id ID #IMPLIED
name %NCName; #REQUIRED
id ID #IMPLIED
%uniqueAttrs;>
<!ELEMENT %key; ((%annotation;)?, %selector;, (%field;)+)>
<!ATTLIST %key;
name %NCName; #IMPLIED
ref %QName; #IMPLIED
id ID #IMPLIED
name %NCName; #REQUIRED
id ID #IMPLIED
%keyAttrs;>
<!ELEMENT %keyref; ((%annotation;)?, %selector;, (%field;)+)>
<!ATTLIST %keyref;
name %NCName; #IMPLIED
ref %QName; #IMPLIED
refer %QName; #IMPLIED
id ID #IMPLIED
name %NCName; #REQUIRED
refer %QName; #REQUIRED
id ID #IMPLIED
%keyrefAttrs;>
<!ELEMENT %selector; ((%annotation;)?)>
<!ATTLIST %selector;
xpath %XPathExpr; #REQUIRED
xpathDefaultNamespace CDATA #IMPLIED
id ID #IMPLIED
xpath %XPathExpr; #REQUIRED
id ID #IMPLIED
%selectorAttrs;>
<!ELEMENT %field; ((%annotation;)?)>
<!ATTLIST %field;
xpath %XPathExpr; #REQUIRED
xpathDefaultNamespace CDATA #IMPLIED
id ID #IMPLIED
xpath %XPathExpr; #REQUIRED
id ID #IMPLIED
%fieldAttrs;>
<!-- co-constraint assertions -->
<!ELEMENT %assert; ((%annotation;)?)>
<!ATTLIST %assert;
test %XPathExpr; #REQUIRED
id ID #IMPLIED
xpathDefaultNamespace CDATA #IMPLIED
%assertAttrs;>
<!-- Schema combination mechanisms -->
<!ELEMENT %include; (%annotation;)?>
<!ATTLIST %include;
@ -434,21 +367,13 @@
id ID #IMPLIED
%redefineAttrs;>
<!ELEMENT %override; ((%annotation;)?,
((%simpleType; | %complexType; | %group; | %attributeGroup;) |
%element; | %attribute; | %notation;)*)>
<!ATTLIST %override;
schemaLocation %URIref; #REQUIRED
id ID #IMPLIED
%overrideAttrs;>
<!ELEMENT %notation; (%annotation;)?>
<!ATTLIST %notation;
name %NCName; #REQUIRED
id ID #IMPLIED
public CDATA #REQUIRED
system %URIref; #IMPLIED
%notationAttrs;>
name %NCName; #REQUIRED
id ID #IMPLIED
public CDATA #REQUIRED
system %URIref; #IMPLIED
%notationAttrs;>
<!-- Annotation is either application information or documentation -->
<!-- By having these here they are available for datatypes as well
@ -475,39 +400,3 @@
'structures' 'http://www.w3.org/2001/XMLSchema.xsd' >
<!NOTATION XML PUBLIC
'REC-xml-1998-0210' 'http://www.w3.org/TR/1998/REC-xml-19980210' >
<!--
In keeping with the XML Schema WG's standard versioning policy,
this DTD will persist at the URI
http://www.w3.org/2012/04/XMLSchema.dtd.
At the date of issue it can also be found at the URI
http://www.w3.org/2009/XMLSchema/XMLSchema.dtd.
The schema document at that URI may however change in the future,
in order to remain compatible with the latest version of XSD
and its namespace. In other words, if XSD or the XML Schema
namespace change, the version of this document at
http://www.w3.org/2009/XMLSchema/XMLSchema.dtd will change accordingly;
the version at http://www.w3.org/2012/04/XMLSchema.dtd
will not change.
Previous dated (and unchanging) versions of this DTD include:
http://www.w3.org/2012/01/XMLSchema.dtd
(XSD 1.1 Proposed Recommendation)
http://www.w3.org/2011/07/XMLSchema.dtd
(XSD 1.1 Candidate Recommendation)
http://www.w3.org/2009/04/XMLSchema.dtd
(XSD 1.1 Candidate Recommendation)
http://www.w3.org/2004/10/XMLSchema.dtd
(XSD 1.0 Recommendation, Second Edition)
http://www.w3.org/2001/05/XMLSchema.dtd
(XSD 1.0 Recommendation, First Edition)
-->

View File

@ -1,8 +1,10 @@
<!--
DTD for XML Schemas: Part 2: Datatypes
Id: datatypes.dtd,v 1.1.2.4 2005/01/31 18:40:42 cmsmcq Exp
Note this DTD is NOT normative, or even definitive.
$Id: datatypes.dtd,v 1.23 2001/03/16 17:36:30 ht Exp $
Note this DTD is NOT normative, or even definitive. - - the
prose copy in the datatypes REC is the definitive version
(which shouldn't differ from this one except for this comment
and entity expansions, but just in case)
-->
<!--
@ -21,7 +23,6 @@
<!ENTITY % minInclusive "%p;minInclusive">
<!ENTITY % totalDigits "%p;totalDigits">
<!ENTITY % fractionDigits "%p;fractionDigits">
<!ENTITY % length "%p;length">
<!ENTITY % minLength "%p;minLength">
<!ENTITY % maxLength "%p;maxLength">
@ -29,13 +30,8 @@
<!ENTITY % whiteSpace "%p;whiteSpace">
<!ENTITY % pattern "%p;pattern">
<!ENTITY % assertion "%p;assertion">
<!ENTITY % explicitTimezone "%p;explicitTimezone">
<!--
Customization entities for the ATTLIST of each element
Customisation entities for the ATTLIST of each element
type. Define one of these if your schema takes advantage
of the anyAttribute='##other' in the schema for schemas
-->
@ -53,12 +49,9 @@
<!ENTITY % lengthAttrs "">
<!ENTITY % minLengthAttrs "">
<!ENTITY % maxLengthAttrs "">
<!ENTITY % enumerationAttrs "">
<!ENTITY % whiteSpaceAttrs "">
<!ENTITY % patternAttrs "">
<!ENTITY % assertionAttrs "">
<!ENTITY % explicitTimezoneAttrs "">
<!-- Define some entities for informative use as attribute
types -->
@ -82,20 +75,18 @@
length, maxLength, minLength within datatype,
and the min- and max- variants of Inclusive and Exclusive
are mutually exclusive. On the other hand, pattern and
enumeration and assertion may repeat.
enumeration may repeat.
-->
<!ENTITY % minBound "(%minInclusive; | %minExclusive;)">
<!ENTITY % maxBound "(%maxInclusive; | %maxExclusive;)">
<!ENTITY % bounds "%minBound; | %maxBound;">
<!ENTITY % numeric "%totalDigits; | %fractionDigits;">
<!ENTITY % numeric "%totalDigits; | %fractionDigits;">
<!ENTITY % ordered "%bounds; | %numeric;">
<!ENTITY % unordered
"%pattern; | %enumeration; | %whiteSpace; | %length; |
%maxLength; | %minLength; | %assertion;
| %explicitTimezone;">
<!ENTITY % implementation-defined-facets "">
<!ENTITY % facet "%ordered; | %unordered; %implementation-defined-facets;">
<!ENTITY % facetAttr
%maxLength; | %minLength;">
<!ENTITY % facet "%ordered; | %unordered;">
<!ENTITY % facetAttr
"value CDATA #REQUIRED
id ID #IMPLIED">
<!ENTITY % fixedAttr "fixed %boolean; #IMPLIED">
@ -210,13 +201,3 @@
<!ATTLIST %pattern;
%facetAttr;
%patternAttrs;>
<!ELEMENT %assertion; %facetModel;>
<!ATTLIST %assertion;
%facetAttr;
%assertionAttrs;>
<!ELEMENT %explicitTimezone; %facetModel;>
<!ATTLIST %explicitTimezone;
%facetAttr;
%explicitTimezoneAttrs;>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,16 +23,20 @@
package common.jdkcatalog;
import java.io.StringReader;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Collectors;
import javax.xml.XMLConstants;
import javax.xml.catalog.Catalog;
import javax.xml.catalog.CatalogFeatures;
import javax.xml.catalog.CatalogManager;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.sax.SAXSource;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import jaxp.library.JAXPTestUtilities;
import org.testng.Assert;
import org.testng.Assert.ThrowingRunnable;
import org.testng.annotations.DataProvider;
@ -44,25 +48,42 @@ import org.xml.sax.helpers.DefaultHandler;
/*
* @test
* @bug 8344800 8345353
* @bug 8344800 8345353 8351969
* @library /javax/xml/jaxp/libs
* @run testng/othervm common.jdkcatalog.JDKCatalogTest
* @summary Verifies the W3C DTDs and XSDs in the JDK built-in catalog.
*/
public class JDKCatalogTest {
static String CLS_DIR = System.getProperty("test.classes");
static String SRC_DIR = System.getProperty("test.src");
public static boolean isWindows = false;
static {
if (System.getProperty("os.name").contains("Windows")) {
isWindows = true;
}
};
public static final String JDKCATALOG_RESOLVE = "jdk.xml.jdkcatalog.resolve";
static final String PUBLIC_ID = "{{publicId}}";
static final String SYSTEM_ID = "{{systemId}}";
static final String XSD_LOCATION = "{{SCHEMA_LOCATION}}";
static final String TARGET_NAMESPACE = "{{targetNamespace}}";
static final String ROOT_ELEMENT = "{{rootElement}}";
private static final String JDKCATALOG_RESOLVE = "jdk.xml.jdkcatalog.resolve";
private static final String PUBLIC_ID = "{{publicId}}";
private static final String SYSTEM_ID = "{{systemId}}";
private static final String XSD_LOCATION = "{{SCHEMA_LOCATION}}";
private static final String TARGET_NAMESPACE = "{{targetNamespace}}";
private static final String ROOT_ELEMENT = "{{rootElement}}";
private static final String JDKCATALOG_URL = "jrt:/java.xml/jdk/xml/internal/jdkcatalog/JDKCatalog.xml";
private Catalog catalog = CatalogManager.catalog(CatalogFeatures.defaults(), URI.create(JDKCATALOG_URL));
/*
* DataProvider: DTDs in the JDK built-in Catalog
* Data provided: public and system Ids, see test testDTDsInJDKCatalog
*/
@DataProvider(name = "DTDsInJDKCatalog")
public Object[][] getDTDsInJDKCatalog() {
return new Object[][]{
// Schema 1.0
{"-//W3C//DTD XMLSCHEMA 200102//EN", "http://www.w3.org/2001/XMLSchema.dtd"},
{"datatypes", "http://www.w3.org/2001/datatypes.dtd"},
// XHTML 1.0
{"-//W3C//DTD XHTML 1.0 Frameset//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"},
{"-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"},
{"-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"},
// XHTML 1.1
{"-//W3C//DTD XHTML 1.1//EN", "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"},
// DTD for W3C specifications
{"-//W3C//DTD Specification V2.10//EN", "http://www.w3.org/2002/xmlspec/dtd/2.10/xmlspec.dtd"},
};
}
/*
* DataProvider: for verifying DTDs in the JDKCatalog
@ -106,6 +127,19 @@ public class JDKCatalogTest {
};
}
/**
* Verifies that the JDK built-in Catalog supports both the Public and System
* identifiers for DTDs.
* @param publicId the public Id
* @param systemId the system Id
*/
@Test(dataProvider = "DTDsInJDKCatalog")
public void testDTDsInJDKCatalog(String publicId, String systemId) {
String matchingPubId = catalog.matchPublic(publicId);
String matchingSysId = catalog.matchSystem(systemId);
Assert.assertEquals(matchingPubId, matchingSysId);
}
/**
* Verifies that references to the W3C DTDs are resolved by the JDK built-in
* catalog.
@ -146,10 +180,10 @@ public class JDKCatalogTest {
public void testXSD(String xmlTemplate, String xsdLocation, String targetNS, String rootElement, String catalog,
Class<Throwable> expectedThrow)
throws Exception {
String xmlSrcPath = SRC_DIR + "/" + xmlTemplate;
String xmlSrcPath = JAXPTestUtilities.SRC_DIR + "/" + xmlTemplate;
final String xmlSrcId = getSysId(xmlSrcPath);
final String customCatalog = getSysId((catalog != null) ? SRC_DIR + "/" + catalog : null);
final String customCatalog = getSysId((catalog != null) ? JAXPTestUtilities.SRC_DIR + "/" + catalog : null);
final String xmlString = generateXMLWithXSDRef(xmlSrcPath, xsdLocation,
targetNS, rootElement);
@ -207,7 +241,7 @@ public class JDKCatalogTest {
*/
private String generateXMLWithDTDRef(String publicId, String systemId)
throws Exception {
Path path = Paths.get(SRC_DIR + "/dtdtest.xml");
Path path = Paths.get(JAXPTestUtilities.SRC_DIR + "/dtdtest.xml");
String xmlString = Files.lines(path).map(line -> {
line = line.replace(PUBLIC_ID, publicId);
line = line.replace(SYSTEM_ID, systemId);
@ -249,7 +283,7 @@ public class JDKCatalogTest {
private String getSysId(String path) {
if (path == null) return null;
String xmlSysId = "file://" + path;
if (isWindows) {
if (JAXPTestUtilities.isWindows) {
path = path.replace('\\', '/');
xmlSysId = "file:///" + path;
}