diff --git a/.gitignore b/.gitignore index 1b15e100..4d5686eb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ api-javaee/src/ api-misc/src/ impl-jboss/src/main/java/ impl-misc/src/main/java/ +impl-javaee/src/main/resources/META-INF/xsd/ +impl-jboss/src/main/resources/META-INF/xsd/ +impl-misc/src/main/resources/META-INF/xsd/ diff --git a/api-javaee/pom.xml b/api-javaee/pom.xml index d033340d..e76409d7 100644 --- a/api-javaee/pom.xml +++ b/api-javaee/pom.xml @@ -24,12 +24,20 @@ shrinkwrap-descriptors-api-base ${project.version} + org.jboss.shrinkwrap.descriptors shrinkwrap-descriptors-gen ${project.version} provided + + + xerces + xercesImpl + 2.10.0 + provided + diff --git a/api-jboss/pom.xml b/api-jboss/pom.xml index 1c3e7f29..6914f7d3 100644 --- a/api-jboss/pom.xml +++ b/api-jboss/pom.xml @@ -30,6 +30,13 @@ ${project.version} provided + + + xerces + xercesImpl + 2.10.0 + provided + diff --git a/api-misc/pom.xml b/api-misc/pom.xml index 4873eb39..bb2ed1d8 100644 --- a/api-misc/pom.xml +++ b/api-misc/pom.xml @@ -30,6 +30,13 @@ ${project.version} provided + + + xerces + xercesImpl + 2.10.0 + provided + diff --git a/gen/.gitignore b/gen/.gitignore index 32c77dbc..07b10305 100644 --- a/gen/.gitignore +++ b/gen/.gitignore @@ -1,4 +1,3 @@ -src/main/java src/test/java src/main/resources/xslt/metadata*.xml >>>>>>> a98e8f7... [SHRINKDESC-62] Splitting api-javaee api-jboss, adding static tests for coverage diff --git a/gen/pom.xml b/gen/pom.xml index 4f83efee..480d5718 100644 --- a/gen/pom.xml +++ b/gen/pom.xml @@ -39,6 +39,14 @@ false + + ../impl-javaee/src/main/resources/META-INF/xsd + + **/*.xsd + **/*.dtd + + false + ../impl-javaee/src/test/java @@ -60,6 +68,14 @@ false + + ../impl-jboss/src/main/resources/META-INF/xsd + + **/*.xsd + **/*.dtd + + false + ../impl-jboss/src/test/java @@ -81,6 +97,14 @@ false + + ../impl-misc/src/main/resources/META-INF/xsd + + **/*.xsd + **/*.dtd + + false + ../impl-misc/src/test/java @@ -125,6 +149,7 @@ ${basedir}/../api-javaee/src/main/java ${basedir}/../impl-javaee/src/main/java + ${basedir}/../impl-javaee/src/main/resources/META-INF/xsd @@ -161,6 +186,7 @@ ${basedir}/../api-javaee/src/main/java ${basedir}/../impl-javaee/src/main/java + ${basedir}/../impl-javaee/src/main/resources/META-INF/xsd @@ -250,6 +276,7 @@ ${basedir}/../api-javaee/src/main/java ${basedir}/../impl-javaee/src/main/java + ${basedir}/../impl-javaee/src/main/resources/META-INF/xsd @@ -444,6 +471,7 @@ ${basedir}/../api-javaee/src/main/java ${basedir}/../impl-javaee/src/main/java + ${basedir}/../impl-javaee/src/main/resources/META-INF/xsd @@ -623,6 +651,7 @@ ${basedir}/../api-jboss/src/main/java ${basedir}/../impl-jboss/src/main/java + ${basedir}/../impl-jboss/src/main/resources/META-INF/xsd @@ -682,7 +711,7 @@ executionJBossEE6 validate - true + false @author @@ -696,6 +725,7 @@ ${basedir}/../api-jboss/src/main/java ${basedir}/../impl-jboss/src/main/java + ${basedir}/../impl-jboss/src/main/resources/META-INF/xsd @@ -770,6 +800,7 @@ ${basedir}/../api-misc/src/main/java ${basedir}/../impl-misc/src/main/java ${basedir}/../impl-misc/src/main/resources/META-INF/services + ${basedir}/../impl-misc/src/main/resources/META-INF/xsd diff --git a/gen/src/main/resources/lib/xdd-printBase.xsl b/gen/src/main/resources/lib/xdd-printBase.xsl deleted file mode 100644 index 18eab389..00000000 --- a/gen/src/main/resources/lib/xdd-printBase.xsl +++ /dev/null @@ -1,714 +0,0 @@ - - - - - - - - - - - package ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // -------------------------------------------------------------------------------------|| - // Constructor - // -------------------------------------------------------------------------------------|| - - - - { - - - - - } - - - { - super(descriptorName); - - addDefaultNamespaces(); - } - - - - - - - - - - - // -------------------------------------------------------------------------------------|| - // Constructor - // -------------------------------------------------------------------------------------|| - - - { - this.t = t; - - - } - - - - { - this.t = t; - - - } - - - - - - - - - - - // -------------------------------------------------------------------------------------|| - // Methods - // -------------------------------------------------------------------------------------|| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public Node getRootNode() - { - - } - - - - - - - - - - // -------------------------------------------------------------------------------------|| - // Namespace - // -------------------------------------------------------------------------------------|| - - - - - - - - { - - - - - } - - - - - - - { - - - } - - - - - - public List<String> getNamespaces() - { - - - - - - - - - - - - } - - - - - - - { - - - - - - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public - - - - - - - - - - - - - - - - - - - - - - - - - // -------------------------------------------------------------------------------------|| - // Instance Members - // -------------------------------------------------------------------------------------|| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gen/src/main/resources/lib/xdd-printElement.xsl b/gen/src/main/resources/lib/xdd-printElement.xsl deleted file mode 100644 index 6c90206b..00000000 --- a/gen/src/main/resources/lib/xdd-printElement.xsl +++ /dev/null @@ -1,2016 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - package ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // -------------------------------------------------------------------------------------|| - // Constructor - // -------------------------------------------------------------------------------------|| - - - - { - - - - - } - - - { - super(descriptorName); - - addDefaultNamespaces(); - } - - - - - - - - - - - // -------------------------------------------------------------------------------------|| - // Constructor - // -------------------------------------------------------------------------------------|| - - - { - this.t = t; - - - } - - - - { - this.t = t; - - - } - - - - - - - - - - - // -------------------------------------------------------------------------------------|| - // Methods - // -------------------------------------------------------------------------------------|| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public Node getRootNode() - { - - } - - - - - - - - - - // -------------------------------------------------------------------------------------|| - // Namespace - // -------------------------------------------------------------------------------------|| - - - - - - - - { - - - - - } - - - - - - - { - - - } - - - - - - public List<String> getNamespaces() - { - - - - - - - - - - - - } - - - - - - - { - - - - - - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public - - - - - - - - - - - - - - - - - - - - - - - - - // -------------------------------------------------------------------------------------|| - // Instance Members - // -------------------------------------------------------------------------------------|| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gen/src/main/resources/lib/xdd-util.xsl b/gen/src/main/resources/lib/xdd-util.xsl deleted file mode 100644 index 97d41efa..00000000 --- a/gen/src/main/resources/lib/xdd-util.xsl +++ /dev/null @@ -1,313 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/gen/src/main/resources/xsd/2001/xml.xsd b/gen/src/main/resources/xsd/2001/xml.xsd new file mode 100644 index 00000000..aea7d0db --- /dev/null +++ b/gen/src/main/resources/xsd/2001/xml.xsd @@ -0,0 +1,287 @@ + + + + + + +
+

About the XML namespace

+ +
+

+ This schema document describes the XML namespace, in a form + suitable for import by other schema documents. +

+

+ See + http://www.w3.org/XML/1998/namespace.html and + + http://www.w3.org/TR/REC-xml for information + about this namespace. +

+

+ Note that local names in this namespace are intended to be + defined only by the World Wide Web Consortium or its subgroups. + The names currently defined in this namespace are listed below. + They should not be used with conflicting semantics by any Working + Group, specification, or document instance. +

+

+ See further below in this document for more information about how to refer to this schema document from your own + XSD schema documents and about the + namespace-versioning policy governing this schema document. +

+
+
+
+
+ + + + +
+ +

lang (as an attribute name)

+

+ denotes an attribute whose value + is a language code for the natural language of the content of + any element; its value is inherited. This name is reserved + by virtue of its definition in the XML specification.

+ +
+
+

Notes

+

+ Attempting to install the relevant ISO 2- and 3-letter + codes as the enumerated possible values is probably never + going to be a realistic possibility. +

+

+ See BCP 47 at + http://www.rfc-editor.org/rfc/bcp/bcp47.txt + and the IANA language subtag registry at + + http://www.iana.org/assignments/language-subtag-registry + for further information. +

+

+ The union allows for the 'un-declaration' of xml:lang with + the empty string. +

+
+
+
+ + + + + + + + + +
+ + + + +
+ +

space (as an attribute name)

+

+ denotes an attribute whose + value is a keyword indicating what whitespace processing + discipline is intended for the content of the element; its + value is inherited. This name is reserved by virtue of its + definition in the XML specification.

+ +
+
+
+ + + + + + +
+ + + +
+ +

base (as an attribute name)

+

+ denotes an attribute whose value + provides a URI to be used as the base for interpreting any + relative URIs in the scope of the element on which it + appears; its value is inherited. This name is reserved + by virtue of its definition in the XML Base specification.

+ +

+ See http://www.w3.org/TR/xmlbase/ + for information about this attribute. +

+
+
+
+
+ + + + +
+ +

id (as an attribute name)

+

+ denotes an attribute whose value + should be interpreted as if declared to be of type ID. + This name is reserved by virtue of its definition in the + xml:id specification.

+ +

+ See http://www.w3.org/TR/xml-id/ + for information about this attribute. +

+
+
+
+
+ + + + + + + + + + +
+ +

Father (in any context at all)

+ +
+

+ denotes Jon Bosak, the chair of + the original XML Working Group. This name is reserved by + the following decision of the W3C XML Plenary and + XML Coordination groups: +

+
+

+ In appreciation for his vision, leadership and + dedication the W3C XML Plenary on this 10th day of + February, 2000, reserves for Jon Bosak in perpetuity + the XML name "xml:Father". +

+
+
+
+
+
+ + + +
+

About this schema document

+ +
+

+ This schema defines attributes and an attribute group suitable + for use by schemas wishing to allow xml:base, + xml:lang, xml:space or + xml:id attributes on elements they define. +

+

+ To enable this, such a schema must import this schema for + the XML namespace, e.g. as follows: +

+
+          <schema . . .>
+           . . .
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+     
+

+ or +

+
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
+     
+

+ Subsequently, qualified reference to any of the attributes or the + group defined below will have the desired effect, e.g. +

+
+          <type . . .>
+           . . .
+           <attributeGroup ref="xml:specialAttrs"/>
+     
+

+ will define a type which will schema-validate an instance element + with any of those attributes. +

+
+
+
+
+ + + +
+

Versioning policy for this schema document

+
+

+ In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + + http://www.w3.org/2009/01/xml.xsd. +

+

+ At the date of issue it can also be found at + + http://www.w3.org/2001/xml.xsd. +

+

+ The schema document at that URI may however change in the future, + in order to remain compatible with the latest version of XML + Schema itself, or with the XML namespace itself. In other words, + if the XML Schema or XML namespaces change, the version of this + document at + http://www.w3.org/2001/xml.xsd + + will change accordingly; the version at + + http://www.w3.org/2009/01/xml.xsd + + will not change. +

+

+ Previous dated (and unchanging) versions of this schema + document are at: +

+ +
+
+
+
+ +
+ diff --git a/gen/src/main/resources/xslt/contributors.xml b/gen/src/main/resources/xslt/contributors.xml deleted file mode 100644 index 79b0003e..00000000 --- a/gen/src/main/resources/xslt/contributors.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/gen/src/main/resources/xslt/copyright.xml b/gen/src/main/resources/xslt/copyright.xml deleted file mode 100644 index a29b4ea5..00000000 --- a/gen/src/main/resources/xslt/copyright.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - /* - * JBoss, Home of Professional Open Source - * Copyright 2011, Red Hat Middleware LLC, and individual contributors - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * Licensed 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. - */ - diff --git a/gen/src/main/resources/xslt/ddJava.xsl b/gen/src/main/resources/xslt/ddJava.xsl deleted file mode 100644 index a42beccc..00000000 --- a/gen/src/main/resources/xslt/ddJava.xsl +++ /dev/null @@ -1,1049 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { - - - _ - - (" - - ") - - , - - - - ; - - - private String value; - - - - - (String value) - { this.value = value; } - - - public String toString() {return value;} - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - : : - - - - - - - - - - - - <T> - extends Child<T> - - { - - - - - - - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - import org.jboss.shrinkwrap.descriptor.api.Descriptor; - import org.jboss.shrinkwrap.descriptor.api.DescriptorNamespace; - - - - { - - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - import org.jboss.shrinkwrap.descriptor.spi.node.Node; - - - - - - - - - <T> - implements Child<T>, - - - { - - - - - - - - - - - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - import org.jboss.shrinkwrap.descriptor.api.DescriptorNamespace; - import org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptorImplBase; - import org.jboss.shrinkwrap.descriptor.impl.base.XMLDate; - import org.jboss.shrinkwrap.descriptor.spi.node.Node; - - - - - - { - - - - - - - - - - - - - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - import org.jboss.shrinkwrap.descriptor.spi.node.Node; - import org.jboss.shrinkwrap.descriptor.gen.TestDescriptorImpl; - import org.jboss.shrinkwrap.descriptor.api.Descriptors; - import org.junit.Test; - import static org.junit.Assert.*; - - - - - - - - - - - - - - - - - - - { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gen/src/main/resources/xslt/experiemental/ddJava-ibm.xsl b/gen/src/main/resources/xslt/experiemental/ddJava-ibm.xsl deleted file mode 100644 index b2eb3785..00000000 --- a/gen/src/main/resources/xslt/experiemental/ddJava-ibm.xsl +++ /dev/null @@ -1,2750 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { - - - _ - - (" - - ") - - , - - - - ; - - - private String value; - - - - - (String value) - { this.value = value; } - - - public String toString() {return value;} - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - : : - - - - - - - - - - - - <T> - extends Child<T> - - { - - - - - - - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - import org.jboss.shrinkwrap.descriptor.api.Descriptor; - import org.jboss.shrinkwrap.descriptor.api.DescriptorNamespace; - - - - - - { - - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - import org.jboss.shrinkwrap.descriptor.spi.node.Node; - - - - - - - - - <T> - implements Child<T>, - - - { - - - - - - - - - - - - - - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - import org.jboss.shrinkwrap.descriptor.api.DescriptorNamespace; - import org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptorImplBase; - import org.jboss.shrinkwrap.descriptor.impl.base.XMLDate; - import org.jboss.shrinkwrap.descriptor.spi.node.Node; - - - - - - - { - - - - - - - - - - - - - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - import org.jboss.shrinkwrap.descriptor.spi.node.Node; - import org.jboss.shrinkwrap.descriptor.gen.TestDescriptorImpl; - import org.jboss.shrinkwrap.descriptor.api.Descriptors; - import org.junit.Test; - import static org.junit.Assert.*; - - - - - - - - - - - - - - - - - - - - - - - - { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - package ; - - - - - - - - - - - - // -------------------------------------------------------------------------------------|| - // Constructor - // -------------------------------------------------------------------------------------|| - - - - { - - - - - } - - - { - super(descriptorName); - - } - - - - - - - - - - - // -------------------------------------------------------------------------------------|| - // Constructor - // -------------------------------------------------------------------------------------|| - - - { - this.t = t; - - - } - - - - { - this.t = t; - - - } - - - - - - - - - - - // -------------------------------------------------------------------------------------|| - // Methods - // -------------------------------------------------------------------------------------|| - - - - - - - - - - - - // -------------------------------------------------------------------------------------|| - // Instance Members - // -------------------------------------------------------------------------------------|| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public Node getRootNode() - { - - } - - - - - - - - - - // -------------------------------------------------------------------------------------|| - // Namespace - // -------------------------------------------------------------------------------------|| - - - { - - - - - } - - - { - - - } - - public List<String> getNamespaces() - { - - - - - - - - - - - - } - - - { - - - - - - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { - - - } - - - - { - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } - - - - - - - - - - - - - - - - } - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - } - - - } - - - - - } - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - } - - - } - - - - - - } - - - - - - - - } - - - - - } - - - - - } - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } - - - - - - - - - - - - - - - - - } - - - - - - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } - - - - } - - - - - - } - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } - - - - } - - - - - - - } - - - - - - - - - } - - - - - - - - - - } - - - - - - - - - } - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gen/src/main/resources/xslt/experiemental/metadata-ibm.xsl b/gen/src/main/resources/xslt/experiemental/metadata-ibm.xsl deleted file mode 100644 index 54c2ba43..00000000 --- a/gen/src/main/resources/xslt/experiemental/metadata-ibm.xsl +++ /dev/null @@ -1,1078 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gen/src/main/resources/xslt/experiemental/metadataIBMEE5.xml b/gen/src/main/resources/xslt/experiemental/metadataIBMEE5.xml deleted file mode 100644 index 32078a2a..00000000 --- a/gen/src/main/resources/xslt/experiemental/metadataIBMEE5.xml +++ /dev/null @@ -1,740 +0,0 @@ - - - - - - - - - - - - - - - - /* - * JBoss, Home of Professional Open Source - * Copyright 2011, Red Hat Middleware LLC, and individual contributors - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * Licensed 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. - */ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UNSPECIFIED - REMOTE - HOME - LOCAL - LOCAL_HOME - SERVICE_ENDPOINT - - - ACTIVITY_SESSION - BEAN_METHOD - - - APPLICATION - CONTAINER_AT_BOUNDARY - - - ROLLBACK - COMMIT - - - TRANSACTION_NONE - TRANSACTION_READ_UNCOMMITTED - TRANSACTION_READ_COMMITTED - TRANSACTION_REPEATABLE_READ - TRANSACTION_SERIALIZABLE - - - DEFAULT - AGGRESSIVE - NORMAL - - - LOOSE - TIGHT - - - Entity - Session - - - java.lang.Boolean - java.lang.Byte - java.lang.Character - java.lang.String - java.lang.Short - java.lang.Integer - java.lang.Long - java.lang.Float - java.lang.Double - - - true - false - yes - no - - - Consumes - Produces - ConsumesProduces - - - Transaction - Extended - - - Application - Container - - - Shareable - Unshareable - - - 1.x - 2.x - - - java.util.Collection - java.util.Set - - - Home - Remote - LocalHome - Local - ServiceEndpoint - - - One - Many - - - Bean - Container - - - Local - Remote - - - Stateful - Stateless - - - NotSupported - Supports - Required - RequiresNew - Mandatory - Never - - - Bean - Container - - - ONCE - ACTIVITY_SESSION - TRANSACTION - - - CALLER_IDENTITY - SPECIFIED_IDENTITY - SYSTEM_IDENTITY - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gen/src/main/resources/xslt/experiemental/schemasIBMEE5.xml b/gen/src/main/resources/xslt/experiemental/schemasIBMEE5.xml deleted file mode 100644 index 8ebd86ad..00000000 --- a/gen/src/main/resources/xslt/experiemental/schemasIBMEE5.xml +++ /dev/null @@ -1,30 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/gen/src/main/resources/xslt/metadata.xsl b/gen/src/main/resources/xslt/metadata.xsl deleted file mode 100644 index 83b8af71..00000000 --- a/gen/src/main/resources/xslt/metadata.xsl +++ /dev/null @@ -1,1412 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gen/src/main/resources/xslt/schemasJ2ee13.xml b/gen/src/main/resources/xslt/schemasJ2ee13.xml deleted file mode 100644 index 3eed9ddc..00000000 --- a/gen/src/main/resources/xslt/schemasJ2ee13.xml +++ /dev/null @@ -1,17 +0,0 @@ - -
- - - - - - - - - - - - - - -
diff --git a/gen/src/main/resources/xslt/schemasJ2ee14.xml b/gen/src/main/resources/xslt/schemasJ2ee14.xml deleted file mode 100644 index 6d85978e..00000000 --- a/gen/src/main/resources/xslt/schemasJ2ee14.xml +++ /dev/null @@ -1,26 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/gen/src/main/resources/xslt/schemasJBossEE5.xml b/gen/src/main/resources/xslt/schemasJBossEE5.xml deleted file mode 100644 index 2055c73f..00000000 --- a/gen/src/main/resources/xslt/schemasJBossEE5.xml +++ /dev/null @@ -1,37 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/gen/src/main/resources/xslt/schemasJBossEE6.xml b/gen/src/main/resources/xslt/schemasJBossEE6.xml deleted file mode 100644 index 26210aee..00000000 --- a/gen/src/main/resources/xslt/schemasJBossEE6.xml +++ /dev/null @@ -1,31 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/gen/src/main/resources/xslt/schemasJavaEE5.xml b/gen/src/main/resources/xslt/schemasJavaEE5.xml deleted file mode 100644 index ea1eb376..00000000 --- a/gen/src/main/resources/xslt/schemasJavaEE5.xml +++ /dev/null @@ -1,42 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/gen/src/main/resources/xslt/schemasJavaEE6.xml b/gen/src/main/resources/xslt/schemasJavaEE6.xml deleted file mode 100644 index a973a20c..00000000 --- a/gen/src/main/resources/xslt/schemasJavaEE6.xml +++ /dev/null @@ -1,83 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/impl-base/pom.xml b/impl-base/pom.xml index 29014c53..911b79b0 100644 --- a/impl-base/pom.xml +++ b/impl-base/pom.xml @@ -25,6 +25,12 @@ ${project.version} + + org.jboss.shrinkwrap.descriptors + shrinkwrap-descriptors-schema-validator + ${project.version} + + junit junit diff --git a/metadata-parser-test/pom.xml b/metadata-parser-test/pom.xml index c866af61..d5e1e437 100644 --- a/metadata-parser-test/pom.xml +++ b/metadata-parser-test/pom.xml @@ -45,6 +45,14 @@
false
+ + ${basedir}/src/main/resources/META-INF/xsd + + **/*.xsd + **/*.dtd + + false + @@ -63,6 +71,7 @@ ${basedir}/src/main/java ${basedir}/src/main/java ${basedir}/src/main/resources/META-INF/services + ${basedir}/src/main/resources/META-INF/xsd diff --git a/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/DtdParserTest.java b/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/DtdParserTest.java index 1552786c..3bac7f21 100644 --- a/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/DtdParserTest.java +++ b/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/DtdParserTest.java @@ -6,6 +6,7 @@ import org.jboss.shrinkwrap.descriptor.metadata.MetadataDescriptor; import org.jboss.shrinkwrap.descriptor.metadata.MetadataElement; import org.jboss.shrinkwrap.descriptor.metadata.MetadataParser; +import org.jboss.shrinkwrap.descriptor.metadata.MetadataParserPath; import org.jboss.shrinkwrap.descriptor.metadata.MetadataUtil; import org.jboss.shrinkwrap.descriptor.metadata.dom.DomWriter; import org.junit.Ignore; @@ -108,7 +109,7 @@ public void testConnector() throws Exception metadata.getMetadataDescriptorList().add(metadataDescriptor); metadata.preResolveDataTypes(); new MetadataUtil().log(metadata); - new DomWriter().write(metadata, "/tmp/connector_1_0.xml", null); + new DomWriter().write(metadata, "/tmp/connector_1_0.xml", null, new MetadataParserPath()); // // if (verbose) { // new MetadataUtil().print(metadata); diff --git a/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/ResourceCopyTestCase.java b/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/ResourceCopyTestCase.java new file mode 100644 index 00000000..6446a539 --- /dev/null +++ b/metadata-parser-test/src/teststatic/java/org/jboss/shrinkwrap/descriptor/test/ironjacamar/ResourceCopyTestCase.java @@ -0,0 +1,25 @@ +package org.jboss.shrinkwrap.descriptor.test.ironjacamar; + +import java.io.File; + +import junit.framework.Assert; + +import org.junit.Test; + + +public class ResourceCopyTestCase +{ + @Test + public void testResourceCopy() throws Exception { + final File connectorDtdFile = new File("src/main/resources/META-INF/xsd/connector_1_0.dtd"); + final File dataSourcesXsdFile = new File("src/main/resources/META-INF/xsd/datasources_1_0.xsd"); + final File ironJacamarXsdFile = new File("src/main/resources/META-INF/xsd/ironjacamar_1_0.xsd"); + final File resourceAdapaterXsdFile = new File("src/main/resources/META-INF/xsd/resource-adapters_1_0.xsd"); + + Assert.assertTrue(connectorDtdFile.exists()); + Assert.assertTrue(dataSourcesXsdFile.exists()); + Assert.assertTrue(ironJacamarXsdFile.exists()); + Assert.assertTrue(resourceAdapaterXsdFile.exists()); + } + +} diff --git a/metadata-parser/pom.xml b/metadata-parser/pom.xml index 9ba6fd43..d626c50f 100644 --- a/metadata-parser/pom.xml +++ b/metadata-parser/pom.xml @@ -58,18 +58,6 @@ - - org.jboss.shrinkwrap.descriptors - shrinkwrap-descriptors-api-base - ${project.version} - - - - org.jboss.shrinkwrap.descriptors - shrinkwrap-descriptors-impl-base - ${project.version} - - org.jboss.shrinkwrap.descriptors shrinkwrap-descriptors-test-util diff --git a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParser.java b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParser.java index 7fd5fa00..408ec862 100644 --- a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParser.java +++ b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParser.java @@ -18,9 +18,12 @@ package org.jboss.shrinkwrap.descriptor.metadata; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; +import java.nio.channels.FileChannel; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -74,8 +77,7 @@ public Metadata getMetadata() * @throws Exception */ @SuppressWarnings("unchecked") -public void parse(final MetadataParserPath path, final List confList, final List javadocTags, final boolean verbose) throws Exception - { + public void parse(final MetadataParserPath path, final List confList, final List javadocTags, final boolean verbose) throws Exception { checkArguments(path, confList); pathToMetadata = createTempFile(verbose); @@ -84,8 +86,7 @@ public void parse(final MetadataParserPath path, final List confList, final L log.fine("Path to temporary metadata file: " + pathToMetadata); } - for (int i = 0; i < confList.size(); i++) - { + for (int i = 0; i < confList.size(); i++) { final MetadataParserConfiguration metadataConf = (MetadataParserConfiguration) confList.get(i); metadata.setCurrentNamespace(metadataConf.getNameSpace()); @@ -104,25 +105,22 @@ public void parse(final MetadataParserPath path, final List confList, final L metadataDescriptor.setGenerateClasses(metadataConf.generateClasses); metadata.getMetadataDescriptorList().add(metadataDescriptor); - if(log.isLoggable(Level.FINE)){ + if (log.isLoggable(Level.FINE)){ log.fine(metadataConf.getPathToXsd()); } - if (metadataConf.getPathToXsd().endsWith(".dtd")) - { + if (metadataConf.getPathToXsd().endsWith(".dtd")) { final InputSource in = new InputSource(new FileReader(metadataConf.getPathToXsd())); final MetadataDtdEventListener dtdEventListener = new MetadataDtdEventListener(metadata, verbose); final DTDParser parser = new DTDParser(); parser.setDtdHandler(dtdEventListener); parser.parse(in); - } - else - { + } else { final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); final DocumentBuilder loader = factory.newDocumentBuilder(); final Document document = loader.parse(metadataConf.getPathToXsd()); - if(log.isLoggable(Level.FINE)){ + if (log.isLoggable(Level.FINE)) { log.fine(document.getDocumentURI()); } @@ -134,7 +132,7 @@ public void parse(final MetadataParserPath path, final List confList, final L filterChain.traverseAndFilter(walker, "", metadata, sb); - if(sb!=null){ + if (sb!=null) { log.info(sb.toString()); } } @@ -146,19 +144,21 @@ public void parse(final MetadataParserPath path, final List confList, final L */ metadata.preResolveDataTypes(); - if (pathToMetadata != null) - { - new DomWriter().write(metadata, pathToMetadata, (List)javadocTags); + if (pathToMetadata != null) { + new DomWriter().write(metadata, pathToMetadata, (List)javadocTags, path); } - if (verbose) - { + if (verbose) { new MetadataUtil().log(metadata); } - if (path.getPathToApi() != null && path.getPathToImpl() != null) - { + if (path.getPathToApi() != null && path.getPathToImpl() != null) { generateCode(path, verbose); + if (path.getPathToResources() != null) { + for (MetadataDescriptor metadataDescriptor: metadata.getMetadataDescriptorList()) { + copyFile(new File(metadataDescriptor.getSchemaName()), path.getPathToResources()); + } + } } } @@ -166,8 +166,8 @@ public void parse(final MetadataParserPath path, final List confList, final L * Generates source code by applying the ddJavaAll.xsl XSLT extracted from the resource stream. * @throws TransformerException */ - public void generateCode(final MetadataParserPath path, final boolean verbose) throws TransformerException - { + public void generateCode(final MetadataParserPath path, final boolean verbose) throws TransformerException { + /** initialize the map which will overwrite global parameters as defined in metadata.xsl/ddJava.xsl */ final Map xsltParameters = new HashMap(); xsltParameters.put("gOutputFolder", path.getPathToImpl()); @@ -189,8 +189,7 @@ public void generateCode(final MetadataParserPath path, final boolean verbose) t * method is executed successfully. * @return full path of the generated metadata XML file. */ - public String getPathToMetadataFile() - { + public String getPathToMetadataFile() { return pathToMetadata; } @@ -203,12 +202,10 @@ public String getPathToMetadataFile() * @return absolute path of the temporary file. * @throws IOException */ - private String createTempFile(final boolean verbose) throws IOException - { + private String createTempFile(final boolean verbose) throws IOException { final File tempFile = File.createTempFile("tempMetadata", ".xml"); - if (!verbose) - { + if (!verbose) { tempFile.deleteOnExit(); } @@ -220,17 +217,45 @@ private String createTempFile(final boolean verbose) throws IOException * @param path * @param confList */ - private void checkArguments(final MetadataParserPath path, final List confList) - { + private void checkArguments(final MetadataParserPath path, final List confList) { if (path == null) { throw new IllegalArgumentException("Invalid configuration. The 'path' element missing!"); - } - else if (confList == null) { + } else if (confList == null) { throw new IllegalArgumentException("Invalid configuration. At least one 'descriptor' element has to be defined!"); - } - else if (confList.isEmpty()) { + } else if (confList.isEmpty()) { throw new IllegalArgumentException("Invalid configuration. At least one 'descriptor' element has to be defined!"); - } - - } + } + } + + + /** + * Copies a file by using NIO. + * @param sourceFile the source file. + * @param destFile the target file location. + * @throws IOException + */ + private void copyFile(File sourceFile, String destPath) throws IOException { + final File destFolder = new File(destPath); + if(!destFolder.exists()) { + destFolder.mkdir(); + } + + FileChannel source = null; + FileChannel destination = null; + + try { + final File destFile = new File(destPath + File.separatorChar + sourceFile.getName()); + source = new FileInputStream(sourceFile).getChannel(); + destination = new FileOutputStream(destFile).getChannel(); + destination.transferFrom(source, 0, source.size()); + } + finally { + if (source != null) { + source.close(); + } + if (destination != null) { + destination.close(); + } + } + } } diff --git a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserPath.java b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserPath.java index 2cc7ad94..2bf686c8 100644 --- a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserPath.java +++ b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserPath.java @@ -50,6 +50,11 @@ public class MetadataParserPath */ protected String pathToServices; + /** + * Full path to the resource folder in which schemas are copied. + * + */ + protected String pathToResources; public String getPathToApi() @@ -91,4 +96,15 @@ public void setPathToServices(final String pathToServices) { this.pathToServices = pathToServices; } + + public String getPathToResources() + { + return pathToResources; + } + + public void setPathToResources(final String pathToResources) + { + this.pathToResources = pathToResources; + } + } diff --git a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/codegen/CodeGen.java b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/codegen/CodeGen.java index a1d7e8e2..94c7fc0a 100644 --- a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/codegen/CodeGen.java +++ b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/codegen/CodeGen.java @@ -19,11 +19,9 @@ import java.io.File; import java.io.IOException; -import java.util.List; import java.util.Map; import org.apache.commons.lang3.text.WordUtils; -import org.jboss.shrinkwrap.descriptor.api.Child; import org.jboss.shrinkwrap.descriptor.metadata.Metadata; import org.jboss.shrinkwrap.descriptor.metadata.MetadataElement; import org.jboss.shrinkwrap.descriptor.metadata.MetadataEnum; @@ -37,8 +35,6 @@ import com.sun.codemodel.JDocComment; import com.sun.codemodel.JExpr; import com.sun.codemodel.JMethod; -import com.sun.codemodel.JType; -import com.sun.codemodel.JTypeVar; /** * Experimental class which may replaced the current xslt based java code generation step. @@ -116,25 +112,25 @@ public void generateInferfaces() throws JClassAlreadyExistsException, IOExceptio // JTypeVar typeVat = new JTypeVar(cm, "T"); // final JDefinedClass dcChild = cm._class(Child.class.getCanonicalName(), ClassType.INTERFACE); - final JClass child = cm.ref(Child.class); - if (child.isParameterized()) - { - List types = child.getTypeParameters(); - for (JClass jclass: types) - { - jclass.toString(); - } - } - - dc._extends(childInterface); - JTypeVar type = dc.generify("T"); - child.narrow(type); - JType erasureType = dc.erasure(); - List types = dc.getTypeParameters(); - for (JClass jclass: types) - { - child.narrow(erasureType); - } +// final JClass child = cm.ref(Child.class); +// if (child.isParameterized()) +// { +// List types = child.getTypeParameters(); +// for (JClass jclass: types) +// { +// jclass.toString(); +// } +// } +// +// dc._extends(childInterface); +// JTypeVar type = dc.generify("T"); +// child.narrow(type); +// JType erasureType = dc.erasure(); +// List types = dc.getTypeParameters(); +// for (JClass jclass: types) +// { +// child.narrow(erasureType); +// } final JDocComment javaDocComment = dc.javadoc(); final Map part = javaDocComment.addXdoclet("author"); diff --git a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/dom/DomWriter.java b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/dom/DomWriter.java index 9fedda1b..e8db2307 100644 --- a/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/dom/DomWriter.java +++ b/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/dom/DomWriter.java @@ -39,6 +39,7 @@ import org.jboss.shrinkwrap.descriptor.metadata.MetadataEnum; import org.jboss.shrinkwrap.descriptor.metadata.MetadataItem; import org.jboss.shrinkwrap.descriptor.metadata.MetadataJavaDoc; +import org.jboss.shrinkwrap.descriptor.metadata.MetadataParserPath; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -61,8 +62,8 @@ public class DomWriter * @param metadata * @param pathToMetadata */ - public void write(final Metadata metadata, final String pathToMetadata, final List javadocTags) - { + public void write(final Metadata metadata, final String pathToMetadata, + final List javadocTags, final MetadataParserPath path) { try { final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); @@ -130,6 +131,13 @@ public void write(final Metadata metadata, final String pathToMetadata, final Li final Attr generateClassImpl = doc.createAttribute("generateClass"); generateClassImpl.setValue(Boolean.toString(descriptor.isGenerateClasses())); packageImpl.setAttributeNode(generateClassImpl); + + if (path.getPathToResources() != null && !path.getPathToResources().isEmpty()) { + final Attr pathToResource = doc.createAttribute("pathToResource"); + pathToResource.setValue(path.getPathToResources()); + packageImpl.setAttributeNode(pathToResource); + } + packages.appendChild(packageImpl); } diff --git a/metadata-parser/src/main/resources/META-INF/ddJavaAll.xsl b/metadata-parser/src/main/resources/META-INF/ddJavaAll.xsl index 389a1887..e52db194 100644 --- a/metadata-parser/src/main/resources/META-INF/ddJavaAll.xsl +++ b/metadata-parser/src/main/resources/META-INF/ddJavaAll.xsl @@ -355,8 +355,8 @@ - - + + @@ -374,12 +374,17 @@ import org.jboss.shrinkwrap.descriptor.api.Descriptor; import org.jboss.shrinkwrap.descriptor.api.DescriptorNamespace; - + import org.apache.xerces.xni.XNIException; + import java.io.IOException; + { + + + @@ -458,11 +463,9 @@ + - - - + @@ -485,8 +488,14 @@ import org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptorImplBase; import org.jboss.shrinkwrap.descriptor.impl.base.XMLDate; import org.jboss.shrinkwrap.descriptor.spi.node.Node; + import org.apache.xerces.xni.XNIException; + import org.jboss.shrinkwrap.descriptor.schemavalidator.XmlValidator; + import org.jboss.shrinkwrap.descriptor.schemavalidator.XmlValidator.SchemaType; + import javax.xml.transform.stream.StreamSource; + import java.io.StringReader; + import java.io.IOException; - + @@ -501,6 +510,9 @@ + + + @@ -2663,6 +2675,41 @@ } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserTest.java b/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserTest.java index 5078759e..cb15aa97 100644 --- a/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserTest.java +++ b/metadata-parser/src/test/java/org/jboss/shrinkwrap/descriptor/metadata/MetadataParserTest.java @@ -1,7 +1,6 @@ package org.jboss.shrinkwrap.descriptor.metadata; import java.io.BufferedReader; -import java.io.File; import java.io.FileReader; import java.net.URL; import java.util.ArrayList; @@ -10,11 +9,8 @@ import junit.framework.Assert; -import org.custommonkey.xmlunit.Difference; -import org.custommonkey.xmlunit.DifferenceListener; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; import org.junit.Test; -import org.w3c.dom.Node; public class MetadataParserTest { diff --git a/pom.xml b/pom.xml index 97b345fd..3dab25cc 100644 --- a/pom.xml +++ b/pom.xml @@ -71,6 +71,7 @@ test-util metadata-parser metadata-parser-test + schema-validator diff --git a/schema-validator/.gitignore b/schema-validator/.gitignore new file mode 100644 index 00000000..41127a89 --- /dev/null +++ b/schema-validator/.gitignore @@ -0,0 +1,8 @@ +.classpath +.project +.settings +target +bin +src/test/java/org/jboss/shrinkwrap/descriptor/api +src/test/java/org/jboss/shrinkwrap/descriptor/impl +log.txt diff --git a/schema-validator/pom.xml b/schema-validator/pom.xml new file mode 100644 index 00000000..66cdc061 --- /dev/null +++ b/schema-validator/pom.xml @@ -0,0 +1,88 @@ + + + + + + org.jboss.shrinkwrap.descriptors + shrinkwrap-descriptors-parent + 2.0.0-alpha-5-SNAPSHOT + ../pom.xml + + + + 4.0.0 + + + shrinkwrap-descriptors-schema-validator + ShrinkWrap Descriptors Schema Validator + XSD and DTD schema validator for the ShrinkWrap Descriptors + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + + + + + + maven-surefire-plugin + + + ${env.JAVA5_HOME}/bin/java + + once + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + + + + + + + org.jboss.shrinkwrap.descriptors + shrinkwrap-descriptors-gen + ${project.version} + test + + + + commons-logging + commons-logging + 1.1 + + + + junit + junit + test + + + + xerces + xercesImpl + 2.10.0 + + + + + diff --git a/schema-validator/src/main/java/org/jboss/shrinkwrap/descriptor/schemavalidator/XmlValidator.java b/schema-validator/src/main/java/org/jboss/shrinkwrap/descriptor/schemavalidator/XmlValidator.java new file mode 100644 index 00000000..f6ecb779 --- /dev/null +++ b/schema-validator/src/main/java/org/jboss/shrinkwrap/descriptor/schemavalidator/XmlValidator.java @@ -0,0 +1,487 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * Licensed 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 org.jboss.shrinkwrap.descriptor.schemavalidator; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringReader; +import java.net.MalformedURLException; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.apache.xerces.parsers.XIncludeAwareParserConfiguration; +import org.apache.xerces.parsers.XMLGrammarPreparser; +import org.apache.xerces.util.SymbolTable; +import org.apache.xerces.util.XMLGrammarPoolImpl; +import org.apache.xerces.xni.XMLResourceIdentifier; +import org.apache.xerces.xni.XNIException; +import org.apache.xerces.xni.grammars.XMLGrammarDescription; +import org.apache.xerces.xni.grammars.XMLGrammarPool; +import org.apache.xerces.xni.parser.XMLEntityResolver; +import org.apache.xerces.xni.parser.XMLErrorHandler; +import org.apache.xerces.xni.parser.XMLInputSource; +import org.apache.xerces.xni.parser.XMLParseException; +import org.apache.xerces.xni.parser.XMLParserConfiguration; + +/** + * This class is able to validate XML files against corresponding + * DTD and XSD schemas. + *

+ * The implementation is based on the xerces xni library. + *

+ * In order to make validations fast, the required schemas should be + * available on the classpath. The implementation searches the resources + * at the following locations: + *

    + *
  1. META-INF/xsd/
  2. + *
  3. xsd/
  4. + *
  5. ./.
  6. + *
  7. META-INF/2001//
  8. + *
+ * + * @author Ralf Battenfeld + * @author Andrew Lee Rubinger + */ +public class XmlValidator { + + /** Defines the schema types */ + public enum SchemaType { + DTD, + XSD + } + + /** contains all search locations used by getResourceAsStream() */ + private List searchLocationList = new CopyOnWriteArrayList(); + + /** schema type we have to know for loading the grammars */ + private final SchemaType schemaType; + + /** preparser and grammar pool */ + private final SymbolTable sym = new SymbolTable(XmlValidatorConstants.BIG_PRIME); + private final XMLGrammarPreparser preparser; + private final XMLGrammarPool grammarPool; + + /** preparser and parser configuration settings */ + private boolean nameSpacesID; + private boolean validationID; + private boolean schemaValidationID; + private boolean schemaFullCheckingID; + private boolean honourAllSchemaID; + + /** used for tracking how many grammars are loaded */ + private int grammarCount = 0; + + /** User specific error handler */ + private XMLErrorHandler errorHandler; + + //-----------------------------------------------------------------------|| + //-- Public Constructors ------------------------------------------------|| + //-----------------------------------------------------------------------|| + + /** + * Default constructor. Initializes the DTD and XSD preparser with + * default settings. + */ + public XmlValidator(final SchemaType type) { + schemaType = type; + grammarPool = new XMLGrammarPoolImpl(); + preparser = new XMLGrammarPreparser(sym); + + if (schemaType == SchemaType.DTD) { + preparser.registerPreparser(XMLGrammarDescription.XML_DTD, null); + } else { + preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null); + } + + preparser.setProperty(XmlValidatorConstants.GRAMMAR_POOL, grammarPool); + nameSpacesID = XmlValidatorConstants.DEFAULT_NAMESPACES_FEATURE_ID; + validationID = XmlValidatorConstants.DEFAULT_VALIDATION_FEATURE_ID; + schemaValidationID = XmlValidatorConstants.DEFAULT_SCHEMA_VALIDATION_FEATURE_ID; + schemaFullCheckingID = XmlValidatorConstants.DEFAULT_SCHEMA_FULL_CHECKING; + honourAllSchemaID = XmlValidatorConstants.DEFAULT_HONOUR_ALL_SCHEMA_LOCATIONS; + + // apply default settings + initializePreparser(); + initializeSearchLocations(); + } + + /** + * Constructs an individual configured validator. + * @param type defines the schema type. + * @param nameSpacesFeatureID the namespaces feature id + * @param validationFeatureID the validation feature id + * @param schemaValidationFeatureID the validation feature id + * @param schemaFullCheckingFeatureID the schema full checking feature id + * @param honourAllSchemaLocationsID the honour all schema locations feature id + */ + public XmlValidator(final SchemaType type, + final boolean nameSpacesFeatureID, + final boolean validationFeatureID, + final boolean schemaValidationFeatureID, + final boolean schemaFullCheckingFeatureID, + final boolean honourAllSchemaLocationsID) { + + schemaType = type; + preparser = new XMLGrammarPreparser(sym); + grammarPool = new XMLGrammarPoolImpl(); + preparser.setProperty(XmlValidatorConstants.GRAMMAR_POOL, grammarPool); + nameSpacesID = nameSpacesFeatureID; + validationID = validationFeatureID; + schemaValidationID = schemaValidationFeatureID; + schemaFullCheckingID = schemaFullCheckingFeatureID; + honourAllSchemaID = honourAllSchemaLocationsID; + + // apply given settings + initializePreparser(); + initializeSearchLocations(); + + if (schemaType == SchemaType.DTD) { + preparser.registerPreparser(XMLGrammarDescription.XML_DTD, null); + } else { + preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null); + } + } + + /** + * Constructor allowing to define the XMLGrammarPreparser and + * XMLGrammarPoolImpl outside of the class. + * @param type defines the schema type. + * @param preparser the preparser created by the caller. + * @param grammarPool the grammar pool created by the caller. + */ + public XmlValidator( + final SchemaType type, + final XMLGrammarPreparser preparser) { + + if (type == null) { + throw new RuntimeException("The schema type must be initialized"); + } + + if (preparser == null) { + throw new RuntimeException("The preparser must be initialized"); + } + + if (preparser.getGrammarPool() == null) { + throw new RuntimeException("The grammar pool must be initialized"); + } + + this.schemaType = type; + this.preparser = preparser; + this.grammarPool = preparser.getGrammarPool(); + + initializeSearchLocations(); + } + + //-----------------------------------------------------------------------|| + //-- Public Grammar Loader Methods --------------------------------------|| + //-----------------------------------------------------------------------|| + + /** + * Installs the user XMLErrorHandler instance. + * @param errorHandler the user specific error handler. + */ + public void setErrorHandler(final XMLErrorHandler errorHandler) { + this.errorHandler = errorHandler; + } + + /** + * Adds a new search location to the existing locations by inserting the + * new location at the first position. + *

+ * A location is an absolute path on the classpath, .e.g 'META-INF/xsd' + * without a leading slash ('/'). + * @param location + */ + public void addSearchLocation(final String location) { + if (!searchLocationList.isEmpty()) { + searchLocationList.add(0, location); + } + else { + searchLocationList.add(location); + } + } + + /** + * Returns the current search locations. + * @return a unmodifiable list of the current search locations. + */ + public List getSearchLocations() { + return Collections.unmodifiableList(searchLocationList); + } + + /** + * Loads the grammar. + * @param schema the grammar to be loaded. + * @throws XNIException + * @throws IOException + */ + public void loadGrammar(final String schema) throws XNIException, IOException { + if (isResourceCandidate(schema)) { + final InputStream inputStream = getFirstValidInputStream(schema); + if (inputStream != null) { + XMLInputSource xmlInputStream = new XMLInputSource(null, + schema, null, inputStream, null); + preparser.preparseGrammar(getGrammarDescription(), xmlInputStream); + } + } else { + preparser.preparseGrammar(getGrammarDescription(), stringToXIS(schema)); + } + grammarCount++; + } + + /** + * Loads the grammars extracted from the given list of schemas. + * @param schemaList + * @throws XNIException + * @throws IOException + */ + public void loadGrammars(final List schemaList) throws XNIException, IOException { + for (String schema: schemaList) { + loadGrammar(schema); + } + } + + //-----------------------------------------------------------------------|| + //-- Public Validator Methods ------------------------------------------|| + //-----------------------------------------------------------------------|| + + public void validateFile(final String pathToFile) throws XNIException, IOException { + checkGrammarPoolSize(); + final XMLParserConfiguration parserConfiguration = getParserConfiguration(); + parserConfiguration.parse(stringToXIS(pathToFile)); + } + + public void validateFile(final File xmlFile) throws XNIException, IOException { + checkGrammarPoolSize(); + validateFile(xmlFile.getAbsolutePath()); + } + + public void validateContent(final String xmlString) throws XNIException, IOException { + checkGrammarPoolSize(); + final XMLParserConfiguration parserConfiguration = getParserConfiguration(); + parserConfiguration.parse(new XMLInputSource(null, null, null, new StringReader(xmlString), null)); + } + + //-----------------------------------------------------------------------|| + //-- Other Public Methods -----------------------------------------------|| + //-----------------------------------------------------------------------|| + + public SchemaType getSchemaType() { + return schemaType; + } + + + //-----------------------------------------------------------------------|| + //-- Private Methods ----------------------------------------------------|| + //-----------------------------------------------------------------------|| + + /** + * Returns the XMLGrammarDescription string based in the schema type. + * @return + */ + private String getGrammarDescription() { + String grammarDescr = null; + if (schemaType == SchemaType.DTD) { + grammarDescr = XMLGrammarDescription.XML_DTD; + } else if (schemaType == SchemaType.XSD) { + grammarDescr = XMLGrammarDescription.XML_SCHEMA; + } else { + throw new RuntimeException("Not supported: " + schemaType); + } + return grammarDescr; + } + + /** + * Returns a XMLParserConfiguration based on the preparser configuration. + * @return a XMLParserConfiguration. + */ + private XMLParserConfiguration getParserConfiguration() { + final XMLParserConfiguration parserConfiguration = new XIncludeAwareParserConfiguration(sym, grammarPool); + + // copy over the parser configuration + parserConfiguration.setFeature(XmlValidatorConstants.NAMESPACES_FEATURE_ID, nameSpacesID); + parserConfiguration.setFeature(XmlValidatorConstants.VALIDATION_FEATURE_ID, validationID); + parserConfiguration.setFeature(XmlValidatorConstants.SCHEMA_VALIDATION_FEATURE_ID, schemaValidationID); + parserConfiguration.setFeature(XmlValidatorConstants.SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullCheckingID); + parserConfiguration.setFeature(XmlValidatorConstants.HONOUR_ALL_SCHEMA_LOCATIONS_ID, honourAllSchemaID); + + // install our own error handler in case no external error hander is defined. + if (errorHandler == null) { + parserConfiguration.setErrorHandler(new ErrorHandler()); + } + + return parserConfiguration; + } + + /** + * Checks that at least one grammar is loaded. + */ + private void checkGrammarPoolSize() { + if (grammarCount == 0) { + throw new RuntimeException("No grammar loaded. Please, load the grammars first"); + } + } + + private void initializePreparser() { + preparser.setProperty(XmlValidatorConstants.GRAMMAR_POOL, grammarPool); + preparser.setFeature(XmlValidatorConstants.NAMESPACES_FEATURE_ID, nameSpacesID); + preparser.setFeature(XmlValidatorConstants.VALIDATION_FEATURE_ID, validationID); + preparser.setFeature(XmlValidatorConstants.SCHEMA_VALIDATION_FEATURE_ID, schemaValidationID); + preparser.setFeature(XmlValidatorConstants.SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullCheckingID); + preparser.setFeature(XmlValidatorConstants.HONOUR_ALL_SCHEMA_LOCATIONS_ID, honourAllSchemaID); + preparser.setEntityResolver(new ResourceStreamResolver()); + } + + /** + * Returns a XMLInputSource object. + * @param uri the URI from which the input source is created. + * @return + */ + private static XMLInputSource stringToXIS(final String uri) { + return new XMLInputSource(null, uri, null); + } + + + //-----------------------------------------------------------------------|| + //-- Private Classes ----------------------------------------------------|| + //-----------------------------------------------------------------------|| + + /** + * This our default entity resolver. This class is able to resolve + * system id's as a resource stream preventing HTTP calls. + */ + private class ResourceStreamResolver implements XMLEntityResolver { + + @Override + public XMLInputSource resolveEntity(final XMLResourceIdentifier resourceIdentifier) + throws XNIException, IOException { + + XMLInputSource xmlInputStream = null; + InputStream inputStream = null; + if (resourceIdentifier.getExpandedSystemId().equals("http://www.w3.org/2001/xml.xsd")) { + inputStream = getFirstValidInputStream("xml.xsd"); + + } else { + // try to get the resource from a resource + inputStream = getInputStream(resourceIdentifier); + } + + if (inputStream != null) { + xmlInputStream = new XMLInputSource(null, + resourceIdentifier.getExpandedSystemId(), null, inputStream, null); + } + + return xmlInputStream; + } + + } + + /** + * Checks if the given resource name starts with a path seperator. If yes, + * then the resource is a File resource. If not, then + * we assume that the resource can be loaded via resource stream. + * @param resourceName + * @return true, if the resource can be loaded via resources stream, otherwise + * it is assumed that the resource is file on the file system. + */ + private boolean isResourceCandidate(final String resourceName) { + if (resourceName.indexOf(File.pathSeparator) >= 0) { + return false; + } + return true; + } + + private InputStream getInputStream(final XMLResourceIdentifier resourceIdentifier) throws MalformedURLException { + final File url = new File(resourceIdentifier.getExpandedSystemId()); + return getFirstValidInputStream(url.getName()); + } + + /** + * Returns the first not nullable InputStream. + * @param resources + * @return the first resolvable InputStream, or null if non of the resources are found. + */ + private InputStream getFirstValidInputStream(final String schema) { + InputStream inputStream = null; + for (String location: searchLocationList) { + inputStream = getClassLoaderForClass(this.getClass()).getResourceAsStream(location + schema); + if (inputStream != null) { + break; + } + } + return inputStream; + } + + /** + * Initializes the location list. + */ + private void initializeSearchLocations() { + searchLocationList.add("META-INF/xsd/"); + searchLocationList.add("xsd/"); + searchLocationList.add(""); + searchLocationList.add("META-INF/2001/"); + } + + /** + * This is our default error handler. + */ + private class ErrorHandler implements XMLErrorHandler { + + @Override + public void warning(String domain, String key, + XMLParseException exception) throws XNIException { + // we ignore warnings + } + + @Override + public void error(String domain, String key, + XMLParseException exception) throws XNIException { + throw new XNIException(exception); + } + + @Override + public void fatalError(String domain, String key, + XMLParseException exception) throws XNIException { + throw new XNIException(exception); + } + } + + /** + * Returns the right ClassLoader. + * @param clazz + * @return + */ + private static ClassLoader getClassLoaderForClass(final Class clazz){ + assert clazz!=null:"Class must be specified"; + if(System.getSecurityManager()==null){ + return clazz.getClassLoader(); + } + else{ + return AccessController.doPrivileged(new PrivilegedAction(){ + + @Override + public ClassLoader run() { + return clazz.getClassLoader(); + }}); + } + } +} diff --git a/schema-validator/src/main/java/org/jboss/shrinkwrap/descriptor/schemavalidator/XmlValidatorConstants.java b/schema-validator/src/main/java/org/jboss/shrinkwrap/descriptor/schemavalidator/XmlValidatorConstants.java new file mode 100644 index 00000000..3e6bc41b --- /dev/null +++ b/schema-validator/src/main/java/org/jboss/shrinkwrap/descriptor/schemavalidator/XmlValidatorConstants.java @@ -0,0 +1,52 @@ +package org.jboss.shrinkwrap.descriptor.schemavalidator; + +import org.apache.xerces.impl.Constants; + +public interface XmlValidatorConstants { + + /** Property identifier: symbol table. */ + public static final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX + + Constants.SYMBOL_TABLE_PROPERTY; + + /** Property identifier: grammar pool. */ + public static final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX + + Constants.XMLGRAMMAR_POOL_PROPERTY; + + /** Namespaces feature id (http://xml.org/sax/features/namespaces). */ + public static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces"; + + /** Validation feature id (http://xml.org/sax/features/validation). */ + public static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation"; + + /** + * Schema validation feature id + * (http://apache.org/xml/features/validation/schema). + */ + public static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema"; + + /** + * Schema full checking feature id + * (http://apache.org/xml/features/validation/schema-full-checking). + */ + public static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking"; + + /** + * Honour all schema locations feature id + * (http://apache.org/xml/features/honour-all-schemaLocations). + */ + public static final String HONOUR_ALL_SCHEMA_LOCATIONS_ID = "http://apache.org/xml/features/honour-all-schemaLocations"; + + // a larg(ish) prime to use for a symbol table to be shared + // among + // potentially man parsers. Start one as close to 2K (20 + // times larger than normal) and see what happens... + public static final int BIG_PRIME = 2039; + + // default settings + public static final boolean DEFAULT_NAMESPACES_FEATURE_ID = true; + public static final boolean DEFAULT_VALIDATION_FEATURE_ID = true; + public static final boolean DEFAULT_SCHEMA_VALIDATION_FEATURE_ID = true; + public static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false; + public static final boolean DEFAULT_HONOUR_ALL_SCHEMA_LOCATIONS = false; + +} diff --git a/schema-validator/src/main/resources/META-INF/2001/xml.xsd b/schema-validator/src/main/resources/META-INF/2001/xml.xsd new file mode 100644 index 00000000..aea7d0db --- /dev/null +++ b/schema-validator/src/main/resources/META-INF/2001/xml.xsd @@ -0,0 +1,287 @@ + + + + + + +

+

About the XML namespace

+ +
+

+ This schema document describes the XML namespace, in a form + suitable for import by other schema documents. +

+

+ See + http://www.w3.org/XML/1998/namespace.html and + + http://www.w3.org/TR/REC-xml for information + about this namespace. +

+

+ Note that local names in this namespace are intended to be + defined only by the World Wide Web Consortium or its subgroups. + The names currently defined in this namespace are listed below. + They should not be used with conflicting semantics by any Working + Group, specification, or document instance. +

+

+ See further below in this document for more information about how to refer to this schema document from your own + XSD schema documents and about the + namespace-versioning policy governing this schema document. +

+
+
+ + + + + + +
+ +

lang (as an attribute name)

+

+ denotes an attribute whose value + is a language code for the natural language of the content of + any element; its value is inherited. This name is reserved + by virtue of its definition in the XML specification.

+ +
+
+

Notes

+

+ Attempting to install the relevant ISO 2- and 3-letter + codes as the enumerated possible values is probably never + going to be a realistic possibility. +

+

+ See BCP 47 at + http://www.rfc-editor.org/rfc/bcp/bcp47.txt + and the IANA language subtag registry at + + http://www.iana.org/assignments/language-subtag-registry + for further information. +

+

+ The union allows for the 'un-declaration' of xml:lang with + the empty string. +

+
+
+
+ + + + + + + + + +
+ + + + +
+ +

space (as an attribute name)

+

+ denotes an attribute whose + value is a keyword indicating what whitespace processing + discipline is intended for the content of the element; its + value is inherited. This name is reserved by virtue of its + definition in the XML specification.

+ +
+
+
+ + + + + + +
+ + + +
+ +

base (as an attribute name)

+

+ denotes an attribute whose value + provides a URI to be used as the base for interpreting any + relative URIs in the scope of the element on which it + appears; its value is inherited. This name is reserved + by virtue of its definition in the XML Base specification.

+ +

+ See http://www.w3.org/TR/xmlbase/ + for information about this attribute. +

+
+
+
+
+ + + + +
+ +

id (as an attribute name)

+

+ denotes an attribute whose value + should be interpreted as if declared to be of type ID. + This name is reserved by virtue of its definition in the + xml:id specification.

+ +

+ See http://www.w3.org/TR/xml-id/ + for information about this attribute. +

+
+
+
+
+ + + + + + + + + + +
+ +

Father (in any context at all)

+ +
+

+ denotes Jon Bosak, the chair of + the original XML Working Group. This name is reserved by + the following decision of the W3C XML Plenary and + XML Coordination groups: +

+
+

+ In appreciation for his vision, leadership and + dedication the W3C XML Plenary on this 10th day of + February, 2000, reserves for Jon Bosak in perpetuity + the XML name "xml:Father". +

+
+
+
+
+
+ + + +
+

About this schema document

+ +
+

+ This schema defines attributes and an attribute group suitable + for use by schemas wishing to allow xml:base, + xml:lang, xml:space or + xml:id attributes on elements they define. +

+

+ To enable this, such a schema must import this schema for + the XML namespace, e.g. as follows: +

+
+          <schema . . .>
+           . . .
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+     
+

+ or +

+
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
+     
+

+ Subsequently, qualified reference to any of the attributes or the + group defined below will have the desired effect, e.g. +

+
+          <type . . .>
+           . . .
+           <attributeGroup ref="xml:specialAttrs"/>
+     
+

+ will define a type which will schema-validate an instance element + with any of those attributes. +

+
+
+
+
+ + + +
+

Versioning policy for this schema document

+
+

+ In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + + http://www.w3.org/2009/01/xml.xsd. +

+

+ At the date of issue it can also be found at + + http://www.w3.org/2001/xml.xsd. +

+

+ The schema document at that URI may however change in the future, + in order to remain compatible with the latest version of XML + Schema itself, or with the XML namespace itself. In other words, + if the XML Schema or XML namespaces change, the version of this + document at + http://www.w3.org/2001/xml.xsd + + will change accordingly; the version at + + http://www.w3.org/2009/01/xml.xsd + + will not change. +

+

+ Previous dated (and unchanging) versions of this schema + document are at: +

+ +
+
+
+
+ + + diff --git a/schema-validator/src/main/resources/META-INF/2004/xml.xsd b/schema-validator/src/main/resources/META-INF/2004/xml.xsd new file mode 100644 index 00000000..9bf636de --- /dev/null +++ b/schema-validator/src/main/resources/META-INF/2004/xml.xsd @@ -0,0 +1,135 @@ + + + + + + + See http://www.w3.org/XML/1998/namespace.html and + http://www.w3.org/TR/REC-xml for information about this namespace. + + This schema document describes the XML namespace, in a form + suitable for import by other schema documents. + + Note that local names in this namespace are intended to be defined + only by the World Wide Web Consortium or its subgroups. The + following names are currently defined in this namespace and should + not be used with conflicting semantics by any Working Group, + specification, or document instance: + + base (as an attribute name): denotes an attribute whose value + provides a URI to be used as the base for interpreting any + relative URIs in the scope of the element on which it + appears; its value is inherited. This name is reserved + by virtue of its definition in the XML Base specification. + + id (as an attribute name): denotes an attribute whose value + should be interpreted as if declared to be of type ID. + The xml:id specification is not yet a W3C Recommendation, + but this attribute is included here to facilitate experimentation + with the mechanisms it proposes. Note that it is _not_ included + in the specialAttrs attribute group. + + lang (as an attribute name): denotes an attribute whose value + is a language code for the natural language of the content of + any element; its value is inherited. This name is reserved + by virtue of its definition in the XML specification. + + space (as an attribute name): denotes an attribute whose + value is a keyword indicating what whitespace processing + discipline is intended for the content of the element; its + value is inherited. This name is reserved by virtue of its + definition in the XML specification. + + Father (in any context at all): denotes Jon Bosak, the chair of + the original XML Working Group. This name is reserved by + the following decision of the W3C XML Plenary and + XML Coordination groups: + + In appreciation for his vision, leadership and dedication + the W3C XML Plenary on this 10th day of February, 2000 + reserves for Jon Bosak in perpetuity the XML name + xml:Father + + + + + This schema defines attributes and an attribute group + suitable for use by + schemas wishing to allow xml:base, xml:lang or xml:space attributes + on elements they define. + + To enable this, such a schema must import this schema + for the XML namespace, e.g. as follows: + <schema . . .> + . . . + <import namespace="http://www.w3.org/XML/1998/namespace" + schemaLocation="http://www.w3.org/2001/03/xml.xsd"/> + + Subsequently, qualified reference to any of the attributes + or the group defined below will have the desired effect, e.g. + + <type . . .> + . . . + <attributeGroup ref="xml:specialAttrs"/> + + will define a type which will schema-validate an instance + element with any of those attributes + + + + In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + http://www.w3.org/2004/10/xml.xsd. + At the date of issue it can also be found at + http://www.w3.org/2001/xml.xsd. + The schema document at that URI may however change in the future, + in order to remain compatible with the latest version of XML Schema + itself, or with the XML namespace itself. In other words, if the XML + Schema or XML namespaces change, the version of this document at + http://www.w3.org/2001/xml.xsd will change + accordingly; the version at + http://www.w3.org/2004/10/xml.xsd will not change. + + + + + + Attempting to install the relevant ISO 2- and 3-letter + codes as the enumerated possible values is probably never + going to be a realistic possibility. See + RFC 3066 at http://www.ietf.org/rfc/rfc3066.txt and the IANA registry + at http://www.iana.org/assignments/lang-tag-apps.htm for + further information. + + + + + + + + + + + + + + + See http://www.w3.org/TR/xmlbase/ for + information about this attribute. + + + + + + See http://www.w3.org/TR/xml-id/ for + information about this attribute. + + + + + + + + + + diff --git a/schema-validator/src/main/resources/META-INF/2007/xml.xsd b/schema-validator/src/main/resources/META-INF/2007/xml.xsd new file mode 100644 index 00000000..eeb9db56 --- /dev/null +++ b/schema-validator/src/main/resources/META-INF/2007/xml.xsd @@ -0,0 +1,145 @@ + + + + + + See http://www.w3.org/XML/1998/namespace.html and + http://www.w3.org/TR/REC-xml for information about this namespace. + + This schema document describes the XML namespace, in a form + suitable for import by other schema documents. + + Note that local names in this namespace are intended to be defined + only by the World Wide Web Consortium or its subgroups. The + following names are currently defined in this namespace and should + not be used with conflicting semantics by any Working Group, + specification, or document instance: + + base (as an attribute name): denotes an attribute whose value + provides a URI to be used as the base for interpreting any + relative URIs in the scope of the element on which it + appears; its value is inherited. This name is reserved + by virtue of its definition in the XML Base specification. + + id (as an attribute name): denotes an attribute whose value + should be interpreted as if declared to be of type ID. + This name is reserved by virtue of its definition in the + xml:id specification. + + lang (as an attribute name): denotes an attribute whose value + is a language code for the natural language of the content of + any element; its value is inherited. This name is reserved + by virtue of its definition in the XML specification. + + space (as an attribute name): denotes an attribute whose + value is a keyword indicating what whitespace processing + discipline is intended for the content of the element; its + value is inherited. This name is reserved by virtue of its + definition in the XML specification. + + Father (in any context at all): denotes Jon Bosak, the chair of + the original XML Working Group. This name is reserved by + the following decision of the W3C XML Plenary and + XML Coordination groups: + + In appreciation for his vision, leadership and dedication + the W3C XML Plenary on this 10th day of February, 2000 + reserves for Jon Bosak in perpetuity the XML name + xml:Father + + + + + This schema defines attributes and an attribute group + suitable for use by + schemas wishing to allow xml:base, xml:lang, xml:space or xml:id + attributes on elements they define. + + To enable this, such a schema must import this schema + for the XML namespace, e.g. as follows: + <schema . . .> + . . . + <import namespace="http://www.w3.org/XML/1998/namespace" + schemaLocation="http://www.w3.org/2001/xml.xsd"/> + + Subsequently, qualified reference to any of the attributes + or the group defined below will have the desired effect, e.g. + + <type . . .> + . . . + <attributeGroup ref="xml:specialAttrs"/> + + will define a type which will schema-validate an instance + element with any of those attributes + + + + In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + http://www.w3.org/2007/08/xml.xsd. + At the date of issue it can also be found at + http://www.w3.org/2001/xml.xsd. + The schema document at that URI may however change in the future, + in order to remain compatible with the latest version of XML Schema + itself, or with the XML namespace itself. In other words, if the XML + Schema or XML namespaces change, the version of this document at + http://www.w3.org/2001/xml.xsd will change + accordingly; the version at + http://www.w3.org/2007/08/xml.xsd will not change. + + + + + + Attempting to install the relevant ISO 2- and 3-letter + codes as the enumerated possible values is probably never + going to be a realistic possibility. See + RFC 3066 at http://www.ietf.org/rfc/rfc3066.txt and the IANA registry + at http://www.iana.org/assignments/lang-tag-apps.htm for + further information. + + The union allows for the 'un-declaration' of xml:lang with + the empty string. + + + + + + + + + + + + + + + + + + + + + + + + See http://www.w3.org/TR/xmlbase/ for + information about this attribute. + + + + + + See http://www.w3.org/TR/xml-id/ for + information about this attribute. + + + + + + + + + + + diff --git a/schema-validator/src/main/resources/META-INF/2009/xml.xsd b/schema-validator/src/main/resources/META-INF/2009/xml.xsd new file mode 100644 index 00000000..bd291f3d --- /dev/null +++ b/schema-validator/src/main/resources/META-INF/2009/xml.xsd @@ -0,0 +1,286 @@ + + + + + + +
+

About the XML namespace

+ +
+

+ This schema document describes the XML namespace, in a form + suitable for import by other schema documents. +

+

+ See + http://www.w3.org/XML/1998/namespace.html and + + http://www.w3.org/TR/REC-xml for information + about this namespace. +

+

+ Note that local names in this namespace are intended to be + defined only by the World Wide Web Consortium or its subgroups. + The names currently defined in this namespace are listed below. + They should not be used with conflicting semantics by any Working + Group, specification, or document instance. +

+

+ See further below in this document for more information about how to refer to this schema document from your own + XSD schema documents and about the + namespace-versioning policy governing this schema document. +

+
+
+
+
+ + + + +
+ +

lang (as an attribute name)

+

+ denotes an attribute whose value + is a language code for the natural language of the content of + any element; its value is inherited. This name is reserved + by virtue of its definition in the XML specification.

+ +
+
+

Notes

+

+ Attempting to install the relevant ISO 2- and 3-letter + codes as the enumerated possible values is probably never + going to be a realistic possibility. +

+

+ See BCP 47 at + http://www.rfc-editor.org/rfc/bcp/bcp47.txt + and the IANA language subtag registry at + + http://www.iana.org/assignments/language-subtag-registry + for further information. +

+

+ The union allows for the 'un-declaration' of xml:lang with + the empty string. +

+
+
+
+ + + + + + + + + +
+ + + + +
+ +

space (as an attribute name)

+

+ denotes an attribute whose + value is a keyword indicating what whitespace processing + discipline is intended for the content of the element; its + value is inherited. This name is reserved by virtue of its + definition in the XML specification.

+ +
+
+
+ + + + + + +
+ + + +
+ +

base (as an attribute name)

+

+ denotes an attribute whose value + provides a URI to be used as the base for interpreting any + relative URIs in the scope of the element on which it + appears; its value is inherited. This name is reserved + by virtue of its definition in the XML Base specification.

+ +

+ See http://www.w3.org/TR/xmlbase/ + for information about this attribute. +

+
+
+
+
+ + + + +
+ +

id (as an attribute name)

+

+ denotes an attribute whose value + should be interpreted as if declared to be of type ID. + This name is reserved by virtue of its definition in the + xml:id specification.

+ +

+ See http://www.w3.org/TR/xml-id/ + for information about this attribute. +

+
+
+
+
+ + + + + + + + + + +
+ +

Father (in any context at all)

+ +
+

+ denotes Jon Bosak, the chair of + the original XML Working Group. This name is reserved by + the following decision of the W3C XML Plenary and + XML Coordination groups: +

+
+

+ In appreciation for his vision, leadership and + dedication the W3C XML Plenary on this 10th day of + February, 2000, reserves for Jon Bosak in perpetuity + the XML name "xml:Father". +

+
+
+
+
+
+ + + +
+

About this schema document

+ +
+

+ This schema defines attributes and an attribute group suitable + for use by schemas wishing to allow xml:base, + xml:lang, xml:space or + xml:id attributes on elements they define. +

+

+ To enable this, such a schema must import this schema for + the XML namespace, e.g. as follows: +

+
+          <schema . . .>
+           . . .
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+     
+

+ or +

+
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
+     
+

+ Subsequently, qualified reference to any of the attributes or the + group defined below will have the desired effect, e.g. +

+
+          <type . . .>
+           . . .
+           <attributeGroup ref="xml:specialAttrs"/>
+     
+

+ will define a type which will schema-validate an instance element + with any of those attributes. +

+
+
+
+
+ + + +
+

Versioning policy for this schema document

+
+

+ In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + + http://www.w3.org/2009/01/xml.xsd. +

+

+ At the date of issue it can also be found at + + http://www.w3.org/2001/xml.xsd. +

+

+ The schema document at that URI may however change in the future, + in order to remain compatible with the latest version of XML + Schema itself, or with the XML namespace itself. In other words, + if the XML Schema or XML namespaces change, the version of this + document at + http://www.w3.org/2001/xml.xsd + + will change accordingly; the version at + + http://www.w3.org/2009/01/xml.xsd + + will not change. +

+

+ Previous dated (and unchanging) versions of this schema + document are at: +

+ +
+
+
+
+ +
diff --git a/schema-validator/src/test/java/org/jboss/shrinkwrap/descriptor/schemavalidator/XmlValidatorTestCase.java b/schema-validator/src/test/java/org/jboss/shrinkwrap/descriptor/schemavalidator/XmlValidatorTestCase.java new file mode 100644 index 00000000..34516529 --- /dev/null +++ b/schema-validator/src/test/java/org/jboss/shrinkwrap/descriptor/schemavalidator/XmlValidatorTestCase.java @@ -0,0 +1,129 @@ +package org.jboss.shrinkwrap.descriptor.schemavalidator; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import junit.framework.Assert; + +import org.apache.xerces.parsers.XMLGrammarPreparser; +import org.apache.xerces.util.SymbolTable; +import org.apache.xerces.xni.XNIException; +import org.jboss.shrinkwrap.descriptor.schemavalidator.XmlValidator.SchemaType; +import org.junit.Test; + +public class XmlValidatorTestCase { + + final XmlValidator defaultValidator = new XmlValidator(SchemaType.XSD); + + public XmlValidatorTestCase() { + try { + defaultValidator.loadGrammar("application_6.xsd"); + } catch (XNIException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Test + public void testXmlValidatorSchemaTypeXSD() { + final XmlValidator validator = new XmlValidator(SchemaType.XSD); + Assert.assertTrue(validator.getSchemaType() == SchemaType.XSD); + } + + @Test + public void testXmlValidatorSchemaTypeDTD() { + final XmlValidator validator = new XmlValidator(SchemaType.DTD); + Assert.assertTrue(validator.getSchemaType() == SchemaType.DTD); + } + + @Test(expected = RuntimeException.class) + public void testXmlValidatorSchemaWithNoConfig() { + new XmlValidator(null, null); + } + + @Test(expected = RuntimeException.class) + public void testXmlValidatorSchemaWithNoParser() { + new XmlValidator(SchemaType.DTD, null); + } + + @Test(expected = RuntimeException.class) + public void testXmlValidatorSchemaWithNoGrammarPool() { + final SymbolTable sym = new SymbolTable(XmlValidatorConstants.BIG_PRIME); + final XMLGrammarPreparser preparser = new XMLGrammarPreparser(sym); + new XmlValidator(SchemaType.DTD, preparser); + } + + @Test + public void testValidApplicationXML() throws Exception { + defaultValidator.validateFile("src/test/resources/test-valid-application-6.xml"); + } + + @Test(expected = XNIException.class) + public void testInvalidApplicationXML() throws Exception { + defaultValidator.validateFile("src/test/resources/test-invalid-application-6.xml"); + } + + @Test + public void testValidApplicationXMLFromList() throws Exception { + final XmlValidator validator = new XmlValidator(SchemaType.XSD); + final List schemas = new ArrayList(); + schemas.add("application_6.xsd"); + validator.loadGrammars(schemas); + validator.validateFile("src/test/resources/test-valid-application-6.xml"); + } + + @Test(expected = XNIException.class) + public void testInvalidApplicationXMLFromList() throws Exception { + final XmlValidator validator = new XmlValidator(SchemaType.XSD); + final List schemas = new ArrayList(); + schemas.add("application_6.xsd"); + validator.loadGrammars(schemas); + validator.validateFile("src/test/resources/test-invalid-application-6.xml"); + } + + @Test + public void testValidApplicationXMLFromStreamSource() throws Exception { + final String resource = getResourceContents("src/test/resources/test-valid-application-6.xml"); + defaultValidator.validateContent(resource); + } + + @Test(expected = XNIException.class) + public void testInvalidApplicationXMLFromStreamSource() throws Exception { + final String resource = getResourceContents("src/test/resources/test-invalid-application-6.xml"); + defaultValidator.validateContent(resource); + } + + @Test + public void testDefaultSearchLocation() throws Exception { + Assert.assertTrue(defaultValidator.getSearchLocations().size() == 4); + } + + @Test + public void testAddSearchLocation() throws Exception { + final XmlValidator validator = new XmlValidator(SchemaType.XSD); + validator.addSearchLocation("META-INF/schema"); + Assert.assertTrue(validator.getSearchLocations().size() == 5); + Assert.assertEquals("META-INF/schema", validator.getSearchLocations().get(0)); + } + + // -------------------------------------------------------------------------------------|| + // Helper Methods ----------------------------------------------------------------------|| + // -------------------------------------------------------------------------------------|| + + private String getResourceContents(String resource) throws Exception { + assert resource != null && resource.length() > 0 : "Resource must be specified"; + final BufferedReader reader = new BufferedReader(new FileReader(resource)); + final StringBuilder builder = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + builder.append(line); + builder.append("\n"); + } + return builder.toString(); + } + +} diff --git a/schema-validator/src/test/resources/test-invalid-application-6.xml b/schema-validator/src/test/resources/test-invalid-application-6.xml new file mode 100644 index 00000000..7cac3d07 --- /dev/null +++ b/schema-validator/src/test/resources/test-invalid-application-6.xml @@ -0,0 +1,19 @@ + + + + test-app + true + + + test-web.war + test + + + + +
rere
+ test-ejb.jar +
+ lib +
\ No newline at end of file diff --git a/schema-validator/src/test/resources/test-valid-application-6.xml b/schema-validator/src/test/resources/test-valid-application-6.xml new file mode 100644 index 00000000..54702440 --- /dev/null +++ b/schema-validator/src/test/resources/test-valid-application-6.xml @@ -0,0 +1,18 @@ + + + + test-app + true + + + test-web.war + test + + + + + test-ejb.jar + + lib + \ No newline at end of file diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/application6/ApplicationDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/application6/ApplicationDescriptorTestCase.java index 257f3eac..42cdc6fb 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/application6/ApplicationDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/application6/ApplicationDescriptorTestCase.java @@ -197,6 +197,8 @@ public void testImportGeneratedApplicationXml() throws Exception String appXmlGenerated = app6Descr.exportAsString(); XmlAssert.assertIdentical(appXmlOriginal, appXmlGenerated); + + app6Descr.validate(); } diff --git a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/beans10/BeansDescriptorTestCase.java b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/beans10/BeansDescriptorTestCase.java index 8cf1f05a..11935f9a 100644 --- a/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/beans10/BeansDescriptorTestCase.java +++ b/test/src/test/java/org/jboss/shrinkwrap/descriptor/test/beans10/BeansDescriptorTestCase.java @@ -17,10 +17,10 @@ package org.jboss.shrinkwrap.descriptor.test.beans10; import java.io.BufferedReader; +import java.io.File; import java.io.FileReader; -import junit.framework.Assert; - +import org.apache.xerces.xni.XNIException; import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.beans10.BeansDescriptor; import org.jboss.shrinkwrap.descriptor.test.util.XmlAssert; @@ -64,7 +64,16 @@ public void testGeneratedXml() throws Exception String webXmlGenerated = beansDescr.exportAsString(); String webXmlOriginal = getResourceContents("src/test/resources/test-gen-beans10.xml"); - XmlAssert.assertIdentical(webXmlOriginal, webXmlGenerated); + XmlAssert.assertIdentical(webXmlOriginal, webXmlGenerated); + + beansDescr.validate(); + } + + @Test(expected = XNIException.class) + public void testInvalidXml() throws Exception + { + final BeansDescriptor beansDD = Descriptors.importAs(BeansDescriptor.class).fromFile(new File("src/test/resources/test-invalid-beans10.xml")); + beansDD.validate(); } //-------------------------------------------------------------------------------------|| diff --git a/test/src/test/resources/test-invalid-beans10.xml b/test/src/test/resources/test-invalid-beans10.xml new file mode 100644 index 00000000..112f91fb --- /dev/null +++ b/test/src/test/resources/test-invalid-beans10.xml @@ -0,0 +1,26 @@ + + + + class0 + class1 + class2 + class3 + class4 + + + class10 + class11 + stereotype0 + stereotype1 + stereotype2 + + + class5 + class6 + class7 + class8 + class9 + +