[jboss-cvs] JBossAS SVN: r72782 - in projects/aop/trunk/aop: docs and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 28 08:31:31 EDT 2008


Author: kabir.khan at jboss.com
Date: 2008-04-28 08:31:31 -0400 (Mon, 28 Apr 2008)
New Revision: 72782

Added:
   projects/aop/trunk/aop/docs/jboss-aop_2_0.xsd
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/schema/
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/schema/SchemaTestCase.java
Removed:
   projects/aop/trunk/aop/docs/jboss-aop_1_0.dtd
Modified:
   projects/aop/trunk/aop/build-tests-jdk50.xml
   projects/aop/trunk/aop/build.xml
   projects/aop/trunk/aop/src/main/org/jboss/aop/AspectXmlLoader.java
Log:
[JBAOP-551] Add schema and add a a test validating all our existing jboss-aop.xml files against the schema

Modified: projects/aop/trunk/aop/build-tests-jdk50.xml
===================================================================
--- projects/aop/trunk/aop/build-tests-jdk50.xml	2008-04-28 12:27:10 UTC (rev 72781)
+++ projects/aop/trunk/aop/build-tests-jdk50.xml	2008-04-28 12:31:31 UTC (rev 72782)
@@ -886,6 +886,7 @@
                <exclude name="org/jboss/test/aop/unit/assignability/ParameterizedTypeTest.class"/>
                <exclude name="org/jboss/test/aop/unit/assignability/VariableTargetAlgorithmTest.class"/>
                <include name="org/jboss/test/aop/ejb3dependencies/EJB3CompatibilityTestCase.class"/>
+               <include name="org/jboss/test/aop/schema/SchemaTestCase.class"/>
             </fileset>
          </batchtest>
       </junit>

Modified: projects/aop/trunk/aop/build.xml
===================================================================
--- projects/aop/trunk/aop/build.xml	2008-04-28 12:27:10 UTC (rev 72781)
+++ projects/aop/trunk/aop/build.xml	2008-04-28 12:31:31 UTC (rev 72782)
@@ -387,7 +387,7 @@
          <fileset dir="${build.classes}">
             <exclude name="org/jboss/aop/standalone/PluggableInstrumentor.class"/>
          </fileset>
-         <fileset file="docs/jboss-aop_1_0.dtd"/>
+         <fileset file="docs/jboss-aop_2_0.xsd"/>
          <fileset file ="${source.etc}/jbossorg-eula.txt"/>
       </jar>
      <jar jarfile="${build.lib}/pluggable-instrumentor.jar"

Deleted: projects/aop/trunk/aop/docs/jboss-aop_1_0.dtd
===================================================================
--- projects/aop/trunk/aop/docs/jboss-aop_1_0.dtd	2008-04-28 12:27:10 UTC (rev 72781)
+++ projects/aop/trunk/aop/docs/jboss-aop_1_0.dtd	2008-04-28 12:31:31 UTC (rev 72782)
@@ -1,108 +0,0 @@
-<?xml version='1.0' encoding='UTF-8' ?>
-
-<!ELEMENT aop (interceptor|introduction|metadata-loader|metadata|
-               stack|aspect|pointcut|pluggable-pointcut|bind|
-               prepare|cflow-stack|dynamic-cflow|annotation-introduction|annotation|typedef|domain)+>
-
-<!ELEMENT domain (interceptor|introduction|metadata-loader|metadata|
-               stack|aspect|pointcut|pluggable-pointcut|bind|
-               prepare|cflow-stack|dynamic-cflow|annotation|annotation-introduction|typedef)+>
-<!ATTLIST domain name CDATA #REQUIRED>
-<!ATTLIST domain extends CDATA #IMPLIED>
-<!ATTLIST domain inheritBindings CDATA #IMPLIED>
-<!ATTLIST domain parentFirst CDATA #IMPLIED>
-
-
-<!ELEMENT interceptor ANY>
-<!ATTLIST interceptor name CDATA #IMPLIED>
-<!ATTLIST interceptor class CDATA #IMPLIED>
-<!ATTLIST interceptor factory CDATA #IMPLIED>
-<!ATTLIST interceptor scope (PER_VM|PER_CLASS|PER_INSTANCE|PER_JOINPOINT|PER_CLASS_JOINPOINT) "PER_VM">
-
-<!ELEMENT aspect ANY>
-<!ATTLIST aspect name CDATA #IMPLIED>
-<!ATTLIST aspect class CDATA #IMPLIED>
-<!ATTLIST aspect factory CDATA #IMPLIED>
-<!ATTLIST aspect scope (PER_VM|PER_CLASS|PER_INSTANCE|PER_JOINPOINT|PER_CLASS_JOINPOINT) "PER_VM">
-
-<!ELEMENT introduction (mixin*,interfaces)>
-<!ATTLIST introduction class CDATA #IMPLIED>
-<!ATTLIST introduction expr CDATA #IMPLIED>
-<!ELEMENT mixin (interfaces, class, construction?)>
-<!ATTLIST mixin transient (true|false) "true">
-<!ELEMENT interfaces (#PCDATA)>
-<!ELEMENT class (#PCDATA)>
-<!ELEMENT construction (#PCDATA)>
-
-<!ELEMENT metadata-loader EMPTY>
-<!ATTLIST metadata-loader tag CDATA #REQUIRED>
-<!ATTLIST metadata-loader class CDATA #REQUIRED>
-
-<!ELEMENT metadata ANY>
-<!ATTLIST metadata tag CDATA #REQUIRED>
-<!ATTLIST metadata class CDATA #REQUIRED>
-
-<!ELEMENT stack (interceptor|interceptor-ref|stack-ref|advice)+>
-<!ATTLIST stack name CDATA #REQUIRED>
-
-<!ELEMENT interceptor-ref EMPTY>
-<!ATTLIST interceptor-ref name CDATA #REQUIRED>
-
-<!ELEMENT stack-ref EMPTY>
-<!ATTLIST stack-ref name CDATA #REQUIRED>
-
-<!ELEMENT advice EMPTY>
-<!ATTLIST advice name CDATA #REQUIRED>
-<!ATTLIST advice aspect CDATA #REQUIRED>
-
-<!ELEMENT pointcut EMPTY>
-<!ATTLIST pointcut name CDATA #REQUIRED>
-<!ATTLIST pointcut expr CDATA #REQUIRED>
-
-<!ELEMENT prepare EMPTY>
-<!ATTLIST prepare expr CDATA #REQUIRED>
-
-<!ELEMENT pluggable-pointcut ANY>
-<!ATTLIST pluggable-pointcut name CDATA #REQUIRED>
-<!ATTLIST pluggable-pointcut class CDATA #REQUIRED>
-
-<!ELEMENT bind (interceptor|interceptor-ref|stack-ref|advice)+>
-<!ATTLIST bind name CDATA #IMPLIED>
-<!ATTLIST bind pointcut CDATA #REQUIRED>
-<!ATTLIST bind cflow CDATA #IMPLIED>
-
-<!ELEMENT cflow-stack (called|not-called)+>
-<!ATTLIST cflow-stack name CDATA #REQUIRED>
-
-<!ELEMENT called EMPTY>
-<!ATTLIST called expr CDATA #REQUIRED>
-<!ELEMENT not-called EMPTY>
-<!ATTLIST not-called expr CDATA #REQUIRED>
-
-
-<!ELEMENT dynamic-cflow EMPTY>
-<!ATTLIST dynamic-cflow name CDATA #REQUIRED>
-<!ATTLIST dynamic-cflow class CDATA #REQUIRED>
-
-<!ELEMENT annotation-introduction (#PCDATA)>
-<!ATTLIST annotation-introduction expr CDATA #REQUIRED>
-<!ATTLIST annotation-introduction invisible (true|false) #REQUIRED>
-
-<!ELEMENT annotation (#PCDATA)>
-<!ATTLIST annotation expr CDATA #REQUIRED>
-
-<!ELEMENT typedef EMPTY>
-<!ATTLIST typedef name CDATA #REQUIRED>
-<!ATTLIST typedef expr CDATA #REQUIRED>
-
-
-
-
-
-
-
-
-
-
-
-

Added: projects/aop/trunk/aop/docs/jboss-aop_2_0.xsd
===================================================================
--- projects/aop/trunk/aop/docs/jboss-aop_2_0.xsd	                        (rev 0)
+++ projects/aop/trunk/aop/docs/jboss-aop_2_0.xsd	2008-04-28 12:31:31 UTC (rev 72782)
@@ -0,0 +1,520 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- A prototype xsd schema for javabeans
+$Id: aop-beans_1_0.xsd 71751 2008-04-06 21:46:33Z kabir.khan at jboss.com $
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+   elementFormDefault="qualified"
+   attributeFormDefault="unqualified"
+   version="1.0"
+>
+
+<!-- 
+   targetNamespace="urn:jboss:aop_xml:2.0"
+   xmlns="urn:jboss:aop_xml:2.0"
+ -->   
+   <xsd:annotation>
+      <xsd:documentation>
+         <![CDATA[
+         A schema for constructing aop beans.
+         ]]>
+      </xsd:documentation>
+   </xsd:annotation>
+
+   <xsd:element name="aop" type="aopType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           An AOP Deployment
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+   </xsd:element>
+
+   <xsd:complexType name="aopType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           An AOP Deployment
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:choice minOccurs="0" maxOccurs="unbounded">
+         <xsd:element name="annotation" type="aopAnnotationType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="annotation-introduction" type="annotationIntroductionType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="arraybind" type="arraybindType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="arrayreplacement" type="arrayreplacementType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="aspect" type="aspectOrInterceptorType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="bind" type="bindType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="cflow-stack" type="cflowStackType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="declare-error" type="declareType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="declare-warning" type="declareType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="domain" type="domainType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="dynamic-cflow" type="dynamicCflowStackType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="interceptor" type="aspectOrInterceptorType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="introduction" type="introductionType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="loader-repository" type="loaderRepositoryType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="metadata" type="metadataType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="metadata-loader" type="metadataLoaderType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="pointcut" type="pointcutType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="precedence" type="precedenceType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="prepare" type="prepareType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="stack" type="stackType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="typedef" type="typedefType" minOccurs="0" maxOccurs="unbounded"/>
+      </xsd:choice>
+   </xsd:complexType>
+
+   <xsd:complexType name="domainType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           An AOP domain
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:choice minOccurs="0" maxOccurs="1">
+         <xsd:element name="annotation" type="aopAnnotationType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="annotation-introduction" type="annotationIntroductionType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="arraybind" type="arraybindType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="arrayreplacement" type="arrayreplacementType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="aspect" type="aspectOrInterceptorType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="bind" type="bindType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="cflow-stack" type="cflowStackType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="declare-error" type="declareType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="declare-warning" type="declareType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="dynamic-cflow" type="dynamicCflowStackType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="interceptor" type="aspectOrInterceptorType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="introduction" type="introductionType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="metadata" type="metadataType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="metadata-loader" type="metadataLoaderType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="pointcut" type="pointcutType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="precedence" type="precedenceType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="prepare" type="prepareType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="stack" type="stackType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="typedef" type="typedefType" minOccurs="0" maxOccurs="unbounded"/>
+      </xsd:choice>
+      <xsd:attribute name="name" type="xsd:string" use="required"/>
+      <xsd:attribute name="parentFirst" type="xsd:boolean" use="optional" default="false"/>
+      <xsd:attribute name="inheritDefinitions" type="xsd:boolean" use="optional" default="true"/>
+      <xsd:attribute name="inheritBindings" type="xsd:boolean" use="optional" default="false"/>
+      <xsd:attribute name="extends" type="xsd:string" use="optional"/>
+   </xsd:complexType> 
+
+   <xsd:complexType name="aspectOrInterceptorType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           aspects or interceptors 
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:choice minOccurs="0" maxOccurs="1">
+         <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded">
+         </xsd:any>
+      </xsd:choice>   
+      <xsd:attribute name="name" type="xsd:string" use="optional"/>
+      <xsd:attribute name="class" type="xsd:string" use="optional"/>
+      <xsd:attribute name="scope" type="xsd:string" use="optional"/>
+      <xsd:attribute name="factory" type="xsd:string" use="optional"/>
+   </xsd:complexType>
+
+   <xsd:complexType name="bindType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           A binding
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:choice minOccurs="1" maxOccurs="unbounded">
+         <xsd:element name="interceptor" type="aspectOrInterceptorType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="interceptor-ref" type="interceptorRefType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="stack-ref" type="stackRefType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="advice" type="adviceType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="around" type="adviceType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="before" type="beforeType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="after" type="afterType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="throwing" type="throwingType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="finally" type="finallyType" minOccurs="0" maxOccurs="unbounded"/>
+      </xsd:choice>
+      <xsd:attribute name="name" type="xsd:string" use="optional" />
+      <xsd:attribute name="pointcut" type="xsd:string" use="required" />
+      <xsd:attribute name="cflow" type="xsd:string" use="optional" />
+   </xsd:complexType>
+
+   <xsd:complexType name="stackType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           An interceptor stack
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:choice minOccurs="1" maxOccurs="unbounded">
+         <xsd:element name="interceptor" type="aspectOrInterceptorType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="interceptor-ref" type="interceptorRefType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="stack-ref" type="stackRefType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="advice" type="adviceType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="around" type="adviceType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="before" type="beforeType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="after" type="afterType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="throwing" type="throwingType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="finally" type="finallyType" minOccurs="0" maxOccurs="unbounded"/>
+      </xsd:choice>
+      <xsd:attribute name="name" type="xsd:string" use="required" />
+   </xsd:complexType>
+
+   <xsd:complexType name="bindContentType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           base type for bind content: stack-ref, interceptor-ref and advice
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:attribute name="name" use="required"/>
+   </xsd:complexType>
+
+   <xsd:complexType name="interceptorRefType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           A interceptor-ref within a bind or intereptor-stack
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:complexContent>
+         <xsd:extension base="bindContentType">
+         </xsd:extension>
+      </xsd:complexContent>
+   </xsd:complexType>
+
+   <xsd:complexType name="stackRefType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           A stack-ref within a bind or interceptor-stack
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:complexContent>
+         <xsd:extension base="bindContentType">
+         </xsd:extension>
+      </xsd:complexContent>
+   </xsd:complexType>
+
+   <xsd:complexType name="adviceType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           A advice or around within a bind or interceptor-stack
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:complexContent>
+         <xsd:extension base="bindContentType">
+            <xsd:attribute name="aspect" type="xsd:string" use="required"/>
+         </xsd:extension>
+      </xsd:complexContent>
+   </xsd:complexType>
+
+   <xsd:complexType name="beforeType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           A before within a bind or interceptor-stack
+           
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:complexContent>
+         <xsd:extension base="adviceType"/>
+      </xsd:complexContent>
+   </xsd:complexType>
+
+   <xsd:complexType name="afterType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           A after within a bind or interceptor-stack
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:complexContent>
+         <xsd:extension base="adviceType"/>
+      </xsd:complexContent>
+   </xsd:complexType>
+
+   <xsd:complexType name="throwingType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           A throwing within a bind or interceptor-stack
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:complexContent>
+         <xsd:extension base="adviceType"/>
+      </xsd:complexContent>
+   </xsd:complexType>
+
+   <xsd:complexType name="finallyType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           A finally within a bind or interceptor-stack
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:complexContent>
+         <xsd:extension base="adviceType"/>
+      </xsd:complexContent>
+   </xsd:complexType>
+
+   <xsd:complexType name="typedefType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           A typedef 
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:attribute name="name" type="xsd:string" use="required"/>
+      <xsd:attribute name="expr" type="xsd:string" use="required"/>
+   </xsd:complexType>
+
+   <xsd:complexType name="cflowStackType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           A cflow-stack 
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:choice minOccurs="1" maxOccurs="unbounded">
+         <xsd:element name="called" type="cflowStackEntryType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="not-called" type="cflowStackEntryType" minOccurs="0" maxOccurs="unbounded"/>
+      </xsd:choice>
+      <xsd:attribute name="name" type="xsd:string" use="required"/>
+   </xsd:complexType>
+   
+   <xsd:complexType name="cflowStackEntryType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           The called or not-called children of cflow-stack
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:attribute name="expr" use="required"/>
+   </xsd:complexType>
+
+   <xsd:complexType name="dynamicCflowStackType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           A dynamic cflow
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:attribute name="name" type="xsd:string" use="required"/>
+      <xsd:attribute name="class" type="xsd:string" use="required"/>
+   </xsd:complexType>
+   
+   <xsd:complexType name="declareType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           A declare-error or declare-warning
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:simpleContent>
+         <xsd:extension base="xsd:string">
+            <xsd:attribute name="name" type="xsd:string" use="optional"/>
+            <xsd:attribute name="expr" type="xsd:string" use="required"/>
+         </xsd:extension>
+      </xsd:simpleContent>
+   </xsd:complexType>
+   
+   <xsd:complexType name="pointcutType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           A named pointcut
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:attribute name="name" type="xsd:string" use="required"/>
+      <xsd:attribute name="expr" type="xsd:string" use="required"/>
+   </xsd:complexType>
+   
+   <xsd:complexType name="prepareType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           A prepare statement
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:attribute name="name" type="xsd:string" use="optional"/>
+      <xsd:attribute name="expr" type="xsd:string" use="required"/>
+   </xsd:complexType>
+
+   <xsd:complexType name="annotationIntroductionType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           A annotation-introduction
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:simpleContent>
+         <xsd:extension base="xsd:string">
+            <xsd:attribute name="expr" type="xsd:string" use="required"/>
+            <xsd:attribute name="invisible" type="xsd:boolean" use="optional"/>
+         </xsd:extension>
+      </xsd:simpleContent>
+   </xsd:complexType>
+
+   <xsd:complexType name="aopAnnotationType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           A annotation override
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:complexContent>
+         <xsd:extension base="annotationIntroductionType"/>
+      </xsd:complexContent>
+   </xsd:complexType>
+
+   <xsd:complexType name="precedenceType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           A annotation override
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:choice minOccurs="1" maxOccurs="unbounded">
+         <xsd:element name="interceptor-ref" type="interceptorRefType" minOccurs="0" maxOccurs="unbounded" />
+         <xsd:element name="advice" type="adviceType" minOccurs="0" maxOccurs="unbounded" />
+      </xsd:choice>
+      <xsd:attribute name="name" type="xsd:string" use="optional"></xsd:attribute>
+   </xsd:complexType>
+
+   <xsd:complexType name="introductionType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           A interface introduction
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:choice minOccurs="1" maxOccurs="unbounded">
+         <xsd:element name="interfaces" type="xsd:string" minOccurs="0" maxOccurs="1" />
+         <xsd:element name="mixin" type="mixinType" minOccurs="0" maxOccurs="unbounded" />
+      </xsd:choice>
+      <xsd:attribute name="class" type="xsd:string" use="optional"></xsd:attribute>
+      <xsd:attribute name="expr" type="xsd:string" use="optional"></xsd:attribute>
+   </xsd:complexType>
+
+   <xsd:complexType name="mixinType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           A mixin within an interface introduction
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:all minOccurs="1" maxOccurs="1">
+         <xsd:element name="interfaces" type="xsd:string" minOccurs="1" maxOccurs="1" />
+         <xsd:element name="class" type="xsd:string" minOccurs="1" maxOccurs="1" />
+         <xsd:element name="construction" type="xsd:string" minOccurs="0" maxOccurs="1" />
+      </xsd:all>
+         <xsd:attribute name="transient" type="xsd:string" use="optional"/>
+   </xsd:complexType>
+
+   <xsd:complexType name="metadataType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           A metadata
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:choice minOccurs="0" maxOccurs="1">
+         <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded">
+         </xsd:any>
+      </xsd:choice>
+      <xsd:attribute name="tag" type="xsd:string" use="required"></xsd:attribute>
+      <xsd:attribute name="class" type="xsd:string" use="required"></xsd:attribute>
+   </xsd:complexType>
+
+   <xsd:complexType name="metadataLoaderType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           A metadata
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:choice minOccurs="0" maxOccurs="1">
+         <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded">
+         </xsd:any>
+      </xsd:choice>
+      <xsd:attribute name="tag" type="xsd:string" use="required"></xsd:attribute>
+      <xsd:attribute name="class" type="xsd:string" use="required"></xsd:attribute>
+   </xsd:complexType>
+
+   <xsd:complexType name="arrayreplacementType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           An array replacement
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:attribute name="name" type="xsd:string" use="optional"></xsd:attribute>
+      <xsd:attribute name="class" type="xsd:string" use="optional"></xsd:attribute>
+      <xsd:attribute name="expr" type="xsd:string" use="optional"></xsd:attribute>
+   </xsd:complexType>
+
+   <xsd:complexType name="arraybindType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           An array binding
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:choice minOccurs="1" maxOccurs="unbounded">
+         <xsd:element name="interceptor" type="aspectOrInterceptorType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="interceptor-ref" type="interceptorRefType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="stack-ref" type="stackRefType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="advice" type="adviceType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="around" type="adviceType" minOccurs="0" maxOccurs="unbounded"/>
+         <!-- b/a/t/f is not supported yet for arrays 
+         <xsd:element name="before" type="beforeType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="after" type="afterType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="throwing" type="throwingType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="finally" type="finallyType" minOccurs="0" maxOccurs="unbounded"/>
+         -->
+      </xsd:choice>
+      <xsd:attribute name="name" type="xsd:string" use="optional"></xsd:attribute>
+      <xsd:attribute name="type" type="xsd:string" use="required"></xsd:attribute>
+   </xsd:complexType>
+   
+   <xsd:simpleType name="loaderRepositoryType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           The name of the loader repository to attach to
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:restriction base="xsd:string">
+      </xsd:restriction>
+   </xsd:simpleType>
+</xsd:schema>

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/AspectXmlLoader.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/AspectXmlLoader.java	2008-04-28 12:27:10 UTC (rev 72781)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/AspectXmlLoader.java	2008-04-28 12:31:31 UTC (rev 72782)
@@ -1433,7 +1433,7 @@
       docBuilderFactory = DocumentBuilderFactory.newInstance();
       docBuilderFactory.setValidating(false);
       InputSource source = new InputSource(is);
-      URL url = AspectXmlLoader.class.getResource("/jboss-aop_1_0.dtd");
+      URL url = AspectXmlLoader.class.getResource("/jboss-aop_2_0.xsd");
       source.setSystemId(url.toString());
       DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
       docBuilder.setEntityResolver(new Resolver());

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/schema/SchemaTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/schema/SchemaTestCase.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/schema/SchemaTestCase.java	2008-04-28 12:31:31 UTC (rev 72782)
@@ -0,0 +1,219 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.schema;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.jboss.aop.AspectXmlLoader;
+import org.jboss.test.aop.AOPTestWithSetup;
+import org.jboss.util.xml.DOMWriter;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class SchemaTestCase extends AOPTestWithSetup
+{
+   
+   public SchemaTestCase(String arg0)
+   {
+      super(arg0);
+   }
+
+   public void testSchema() throws Exception
+   {
+      URL schemaUrl = AspectXmlLoader.class.getResource("/jboss-aop_2_0.xsd");
+      assertNotNull(schemaUrl);
+      Schema schema = getSchema(schemaUrl);
+      List<File> files = getAopXmlFiles();
+      for (File file : files)
+      {
+         System.out.println("Validating " + file);
+         Reader rdr = massageFile(file, schemaUrl);
+         parseAndValidateXmlFile(rdr, schema);
+      }
+   }
+   
+   private void parseAndValidateXmlFile(Reader reader, Schema schema) throws Exception
+   {
+      MyErrorHandler handler = new MyErrorHandler();
+      try
+      {
+         DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+         docBuilderFactory.setNamespaceAware(true);
+         docBuilderFactory.setValidating(true);
+         docBuilderFactory.setAttribute("http://apache.org/xml/features/validation/schema", true);
+         docBuilderFactory.setSchema(schema);
+         InputSource source = new InputSource(reader);
+
+         DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+         docBuilder.setErrorHandler(handler);
+         docBuilder.parse(source);
+      }
+      catch(Exception e)
+      {
+         throw new Exception("Error reading file", e);
+      }
+      finally
+      {
+         reader.close();
+      }
+      
+      if (handler.getType() != null && handler.getException() != null)
+      {
+         throw new Exception(handler.getType(), handler.getException());
+      }
+   }
+   
+   private Reader massageFile(File file, URL schemaUrl) throws Exception
+   {
+      Reader is = new BufferedReader(new FileReader(file));
+      try
+      {
+         DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+         InputSource source = new InputSource(is);
+   
+         DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+         Document doc = docBuilder.parse(source);
+         
+         Element root = doc.getDocumentElement();
+         NamedNodeMap map = root.getAttributes();
+
+         if (map.getLength() == 0)
+         {
+            StringWriter writer = new StringWriter();
+            
+            root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
+            root.setAttribute("xsi:noNamespaceSchemaLocation", schemaUrl.toString());
+
+            DOMWriter domWriter = new DOMWriter(new BufferedWriter(writer));
+            domWriter.setWriteXMLDeclaration(true);
+            domWriter.print(doc);
+            
+            return new StringReader(writer.getBuffer().toString());
+         }
+      }
+      finally
+      {
+         is.close();
+      }
+      
+      return new BufferedReader(new FileReader(file));
+   }
+   
+   private Schema getSchema(URL url) throws SAXException
+   {
+      SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+      Schema schema = factory.newSchema(url);
+      return schema;
+   }
+   
+   private List<File> getAopXmlFiles() throws IOException, URISyntaxException
+   {
+      URL url = getURLRelativeToProjectRoot("/src/resources/test/");
+      File root = new File(url.toURI());
+      List<File> files = new ArrayList<File>();
+      getAopXmlFiles(files, root);
+      return files;
+   }
+   
+   private void getAopXmlFiles(List<File> files, File directory)
+   {
+      File[] dirFiles = directory.listFiles();
+      for (File file : dirFiles)
+      {
+         if (file.getName().equals(".svn"))
+         {
+            continue;
+         }
+         if (file.isDirectory())
+         {
+            getAopXmlFiles(files, file);
+            continue;
+         }
+         
+         if (file.getPath().endsWith("-aop.xml"))
+         {
+            files.add(file);
+         }
+      }
+   }
+   
+   private static class MyErrorHandler implements ErrorHandler
+   {
+      String type;
+      SAXParseException exception;
+      
+      public void error(SAXParseException exception) throws SAXException
+      {
+         this.exception = exception;
+         type = "Parser Error";
+      }
+
+      public void fatalError(SAXParseException exception) throws SAXException
+      {
+         this.exception = exception;
+         type = "Parser Fatal Error";
+      }
+
+      public void warning(SAXParseException exception) throws SAXException
+      {
+         this.exception = exception;
+         type = "Parser Warning";
+      }
+
+      protected String getType()
+      {
+         return type;
+      }
+
+      protected SAXParseException getException()
+      {
+         return exception;
+      }
+   }     
+}




More information about the jboss-cvs-commits mailing list