[jboss-svn-commits] JBoss Common SVN: r2957 - in jbossxb/trunk/src: main/java/org/jboss/xb/builder and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jan 14 11:35:19 EST 2009
Author: alex.loubyansky at jboss.com
Date: 2009-01-14 11:35:18 -0500 (Wed, 14 Jan 2009)
New Revision: 2957
Added:
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementFalseApplyToTypeFalse.java
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementFalseApplyToTypeTrue.java
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementTrueApplyToTypeFalse.java
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementTrueApplyToTypeTrue.java
Removed:
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToChildrenFalse.java
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToChildrenTrue.java
Modified:
jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlNsPrefix.java
jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/test/JBossXmlNsPrefixUnitTestCase.java
Log:
JBXB-168
Modified: jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlNsPrefix.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlNsPrefix.java 2009-01-14 15:49:13 UTC (rev 2956)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlNsPrefix.java 2009-01-14 16:35:18 UTC (rev 2957)
@@ -56,9 +56,20 @@
boolean schemaTargetIfNotMapped() default false;
/**
- * Whether child elements (and their types) should also be bound to the namespace the prefix is mapped to
+ * True means the element the property is bound to will be bound to the namespace specified by the prefix.
+ * False means the element will be in the schema's target namespace.
*
* @return
*/
- boolean applyToChildren() default true;
+ boolean applyToElement() default true;
+
+ /**
+ * True means the type of the property (with its child elements and their types recursively)
+ * will be bound to the namespace specified by the prefix.
+ * False means the type of the property (with its child elements and their types recursively)
+ * will be bound to the schema's target namespace.
+ *
+ * @return
+ */
+ boolean applyToType() default true;
}
Modified: jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java 2009-01-14 15:49:13 UTC (rev 2956)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java 2009-01-14 16:35:18 UTC (rev 2957)
@@ -1594,21 +1594,20 @@
String overridenDefaultNamespace = defaultNamespace;
if (xmlNsPrefix != null)
{
- overrideNamespace = schemaBinding.getNamespace(xmlNsPrefix.prefix());
- if (overrideNamespace == null)
+ String prefixNs = schemaBinding.getNamespace(xmlNsPrefix.prefix());
+ if (prefixNs == null)
{
if (xmlNsPrefix.schemaTargetIfNotMapped())
- {
- overrideNamespace = defaultNamespace;
- }
+ prefixNs = defaultNamespace;
else
- {
- throw new IllegalStateException("Prefix '" + xmlNsPrefix.prefix()
- + "' is not mapped to any namespace!");
- }
+ throw new IllegalStateException("Prefix '" + xmlNsPrefix.prefix() + "' is not mapped to any namespace!");
}
- else if(xmlNsPrefix.applyToChildren())
- defaultNamespace = overrideNamespace;
+
+ if(xmlNsPrefix.applyToElement())
+ overrideNamespace = prefixNs;
+
+ if(xmlNsPrefix.applyToType())
+ defaultNamespace = prefixNs;
}
// Determine the name
Deleted: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToChildrenFalse.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToChildrenFalse.java 2009-01-14 15:49:13 UTC (rev 2956)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToChildrenFalse.java 2009-01-14 16:35:18 UTC (rev 2957)
@@ -1,68 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.xb.builder.object.element.jbossxmlnsprefix.support;
-
-import javax.xml.bind.annotation.XmlNs;
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-import org.jboss.xb.annotations.JBossXmlNsPrefix;
-import org.jboss.xb.annotations.JBossXmlSchema;
-
-/**
- * A Root.
- *
- * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
- * @version $Revision: 1.1 $
- */
- at XmlRootElement(name="root")
- at JBossXmlSchema(namespace = "ns.root",
- xmlns={@XmlNs(namespaceURI = "ns.child", prefix = "child")},
- elementFormDefault=XmlNsForm.QUALIFIED)
- at XmlType(propOrder={"child", "rootName"})
-public class ApplyToChildrenFalse
-{
- private String rootName;
- private Child child;
-
- public String getRootName()
- {
- return rootName;
- }
-
- public void setRootName(String rootName)
- {
- this.rootName = rootName;
- }
-
- @JBossXmlNsPrefix(prefix = "child", applyToChildren=false)
- public Child getChild()
- {
- return child;
- }
-
- public void setChild(Child child)
- {
- this.child = child;
- }
-}
Deleted: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToChildrenTrue.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToChildrenTrue.java 2009-01-14 15:49:13 UTC (rev 2956)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToChildrenTrue.java 2009-01-14 16:35:18 UTC (rev 2957)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.xb.builder.object.element.jbossxmlnsprefix.support;
-
-import javax.xml.bind.annotation.XmlNs;
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.jboss.xb.annotations.JBossXmlNsPrefix;
-import org.jboss.xb.annotations.JBossXmlSchema;
-
-/**
- * A Root.
- *
- * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
- * @version $Revision: 1.1 $
- */
- at XmlRootElement(name="root")
- at JBossXmlSchema(namespace = "ns.root",
- xmlns={@XmlNs(namespaceURI = "ns.child", prefix = "child")},
- elementFormDefault=XmlNsForm.QUALIFIED)
-public class ApplyToChildrenTrue
-{
- private Child child;
-
- @JBossXmlNsPrefix(prefix = "child", applyToChildren=true)
- public Child getChild()
- {
- return child;
- }
-
- public void setChild(Child child)
- {
- this.child = child;
- }
-}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementFalseApplyToTypeFalse.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementFalseApplyToTypeFalse.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementFalseApplyToTypeFalse.java 2009-01-14 16:35:18 UTC (rev 2957)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.xb.builder.object.element.jbossxmlnsprefix.support;
+
+import javax.xml.bind.annotation.XmlNs;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.xb.annotations.JBossXmlNsPrefix;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * A Root.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+ at XmlRootElement(name="root")
+ at JBossXmlSchema(namespace = "ns.root",
+ xmlns={@XmlNs(namespaceURI = "ns.child", prefix = "child")},
+ elementFormDefault=XmlNsForm.QUALIFIED)
+ at XmlType(propOrder={"child", "rootName"})
+public class ApplyToElementFalseApplyToTypeFalse
+{
+ private String rootName;
+ private Child child;
+
+ public String getRootName()
+ {
+ return rootName;
+ }
+
+ public void setRootName(String rootName)
+ {
+ this.rootName = rootName;
+ }
+
+ @JBossXmlNsPrefix(prefix = "child", applyToElement=false, applyToType=false)
+ public Child getChild()
+ {
+ return child;
+ }
+
+ public void setChild(Child child)
+ {
+ this.child = child;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementFalseApplyToTypeTrue.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementFalseApplyToTypeTrue.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementFalseApplyToTypeTrue.java 2009-01-14 16:35:18 UTC (rev 2957)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.xb.builder.object.element.jbossxmlnsprefix.support;
+
+import javax.xml.bind.annotation.XmlNs;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.xb.annotations.JBossXmlNsPrefix;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * A Root.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+ at XmlRootElement(name="root")
+ at JBossXmlSchema(namespace = "ns.root",
+ xmlns={@XmlNs(namespaceURI = "ns.child", prefix = "child")},
+ elementFormDefault=XmlNsForm.QUALIFIED)
+ at XmlType(propOrder={"child", "rootName"})
+public class ApplyToElementFalseApplyToTypeTrue
+{
+ private String rootName;
+ private Child child;
+
+ public String getRootName()
+ {
+ return rootName;
+ }
+
+ public void setRootName(String rootName)
+ {
+ this.rootName = rootName;
+ }
+
+ @JBossXmlNsPrefix(prefix = "child", applyToElement=false, applyToType=true)
+ public Child getChild()
+ {
+ return child;
+ }
+
+ public void setChild(Child child)
+ {
+ this.child = child;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementTrueApplyToTypeFalse.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementTrueApplyToTypeFalse.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementTrueApplyToTypeFalse.java 2009-01-14 16:35:18 UTC (rev 2957)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.xb.builder.object.element.jbossxmlnsprefix.support;
+
+import javax.xml.bind.annotation.XmlNs;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.xb.annotations.JBossXmlNsPrefix;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * A Root.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+ at XmlRootElement(name="root")
+ at JBossXmlSchema(namespace = "ns.root",
+ xmlns={@XmlNs(namespaceURI = "ns.child", prefix = "child")},
+ elementFormDefault=XmlNsForm.QUALIFIED)
+ at XmlType(propOrder={"child", "rootName"})
+public class ApplyToElementTrueApplyToTypeFalse
+{
+ private String rootName;
+ private Child child;
+
+ public String getRootName()
+ {
+ return rootName;
+ }
+
+ public void setRootName(String rootName)
+ {
+ this.rootName = rootName;
+ }
+
+ @JBossXmlNsPrefix(prefix = "child", applyToElement=true, applyToType=false)
+ public Child getChild()
+ {
+ return child;
+ }
+
+ public void setChild(Child child)
+ {
+ this.child = child;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementTrueApplyToTypeTrue.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementTrueApplyToTypeTrue.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/support/ApplyToElementTrueApplyToTypeTrue.java 2009-01-14 16:35:18 UTC (rev 2957)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.xb.builder.object.element.jbossxmlnsprefix.support;
+
+import javax.xml.bind.annotation.XmlNs;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.jboss.xb.annotations.JBossXmlNsPrefix;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * A Root.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+ at XmlRootElement(name="root")
+ at JBossXmlSchema(namespace = "ns.root",
+ xmlns={@XmlNs(namespaceURI = "ns.child", prefix = "child")},
+ elementFormDefault=XmlNsForm.QUALIFIED)
+public class ApplyToElementTrueApplyToTypeTrue
+{
+ private Child child;
+
+ @JBossXmlNsPrefix(prefix = "child", applyToType=true)
+ public Child getChild()
+ {
+ return child;
+ }
+
+ public void setChild(Child child)
+ {
+ this.child = child;
+ }
+}
Modified: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/test/JBossXmlNsPrefixUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/test/JBossXmlNsPrefixUnitTestCase.java 2009-01-14 15:49:13 UTC (rev 2956)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/element/jbossxmlnsprefix/test/JBossXmlNsPrefixUnitTestCase.java 2009-01-14 16:35:18 UTC (rev 2957)
@@ -27,15 +27,16 @@
import javax.xml.namespace.QName;
import org.jboss.test.xb.builder.AbstractBuilderTest;
-import org.jboss.test.xb.builder.object.element.jbossxmlnsprefix.support.ApplyToChildrenFalse;
+import org.jboss.test.xb.builder.object.element.jbossxmlnsprefix.support.ApplyToElementFalseApplyToTypeTrue;
+import org.jboss.test.xb.builder.object.element.jbossxmlnsprefix.support.ApplyToElementTrueApplyToTypeFalse;
+import org.jboss.test.xb.builder.object.element.jbossxmlnsprefix.support.ApplyToElementFalseApplyToTypeFalse;
import org.jboss.test.xb.builder.object.element.jbossxmlnsprefix.support.MissingPrefixMappingException;
import org.jboss.test.xb.builder.object.element.jbossxmlnsprefix.support.MissingPrefixMappingGoesTarget;
-import org.jboss.test.xb.builder.object.element.jbossxmlnsprefix.support.ApplyToChildrenTrue;
+import org.jboss.test.xb.builder.object.element.jbossxmlnsprefix.support.ApplyToElementTrueApplyToTypeTrue;
import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
import org.jboss.xb.binding.sunday.unmarshalling.ModelGroupBinding;
import org.jboss.xb.binding.sunday.unmarshalling.ParticleBinding;
import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
-import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
import org.jboss.xb.builder.JBossXBBuilder;
/**
@@ -55,7 +56,7 @@
{
try
{
- JBossXBBuilder.build(MissingPrefixMappingException.class);
+ JBossXBBuilder.build(MissingPrefixMappingException.class, true);
fail("didn't throw an exception for the unmapped prefix");
}
catch(RuntimeException e)
@@ -66,7 +67,7 @@
public void testMissingPrefixGoesTarget() throws Exception
{
- SchemaBinding schema = JBossXBBuilder.build(MissingPrefixMappingGoesTarget.class);
+ SchemaBinding schema = JBossXBBuilder.build(MissingPrefixMappingGoesTarget.class, true);
Iterator<ElementBinding> elements = schema.getElements();
assertTrue(elements.hasNext());
@@ -92,9 +93,9 @@
assertEquals(new QName("ns.root", "name"), e.getQName());
}
- public void testApplyToChildrenTrue()
+ public void testApplyToElementTrueApplyToTypeTrue()
{
- SchemaBinding schema = JBossXBBuilder.build(ApplyToChildrenTrue.class);
+ SchemaBinding schema = JBossXBBuilder.build(ApplyToElementTrueApplyToTypeTrue.class, true);
assertNotNull(schema);
Iterator<ElementBinding> elements = schema.getElements();
assertTrue(elements.hasNext());
@@ -121,9 +122,9 @@
assertEquals(new QName("ns.child", "name"), e.getQName());
}
- public void testApplyToChildrenFalse()
+ public void testApplyToElementTrueApplyToTypeFalse()
{
- SchemaBinding schema = JBossXBBuilder.build(ApplyToChildrenFalse.class);
+ SchemaBinding schema = JBossXBBuilder.build(ApplyToElementTrueApplyToTypeFalse.class, true);
assertNotNull(schema);
Iterator<ElementBinding> elements = schema.getElements();
assertTrue(elements.hasNext());
@@ -155,4 +156,74 @@
e = (ElementBinding) particle.getTerm();
assertEquals(new QName("ns.root", "root-name"), e.getQName());
}
+
+ public void testApplyToElementFalseApplyToTypeFalse()
+ {
+ SchemaBinding schema = JBossXBBuilder.build(ApplyToElementFalseApplyToTypeFalse.class, true);
+ assertNotNull(schema);
+ Iterator<ElementBinding> elements = schema.getElements();
+ assertTrue(elements.hasNext());
+
+ //root
+ ElementBinding e = elements.next();
+ assertFalse(elements.hasNext());
+ assertEquals(new QName("ns.root", "root"), e.getQName());
+ ModelGroupBinding group = (ModelGroupBinding) e.getType().getParticle().getTerm();
+ Collection<ParticleBinding> particles = group.getParticles();
+ assertEquals(2, particles.size());
+ Iterator<ParticleBinding> particleIterator = particles.iterator();
+ ParticleBinding particle = particleIterator.next();
+
+ // child
+ e = (ElementBinding) particle.getTerm();
+ assertEquals(new QName("ns.root", "child"), e.getQName());
+ group = (ModelGroupBinding) e.getType().getParticle().getTerm();
+ particles = group.getParticles();
+ assertEquals(1, particles.size());
+ particle = particles.iterator().next();
+
+ // child/name
+ e = (ElementBinding) particle.getTerm();
+ assertEquals(new QName("ns.root", "name"), e.getQName());
+
+ // rootName
+ particle = particleIterator.next();
+ e = (ElementBinding) particle.getTerm();
+ assertEquals(new QName("ns.root", "root-name"), e.getQName());
+ }
+
+ public void testApplyToElementFalseApplyToTypeTrue()
+ {
+ SchemaBinding schema = JBossXBBuilder.build(ApplyToElementFalseApplyToTypeTrue.class, true);
+ assertNotNull(schema);
+ Iterator<ElementBinding> elements = schema.getElements();
+ assertTrue(elements.hasNext());
+
+ //root
+ ElementBinding e = elements.next();
+ assertFalse(elements.hasNext());
+ assertEquals(new QName("ns.root", "root"), e.getQName());
+ ModelGroupBinding group = (ModelGroupBinding) e.getType().getParticle().getTerm();
+ Collection<ParticleBinding> particles = group.getParticles();
+ assertEquals(2, particles.size());
+ Iterator<ParticleBinding> particleIterator = particles.iterator();
+ ParticleBinding particle = particleIterator.next();
+
+ // child
+ e = (ElementBinding) particle.getTerm();
+ assertEquals(new QName("ns.child", "child"), e.getQName());
+ group = (ModelGroupBinding) e.getType().getParticle().getTerm();
+ particles = group.getParticles();
+ assertEquals(1, particles.size());
+ particle = particles.iterator().next();
+
+ // child/name
+ e = (ElementBinding) particle.getTerm();
+ assertEquals(new QName("ns.child", "name"), e.getQName());
+
+ // rootName
+ particle = particleIterator.next();
+ e = (ElementBinding) particle.getTerm();
+ assertEquals(new QName("ns.root", "root-name"), e.getQName());
+ }
}
More information about the jboss-svn-commits
mailing list