users@jaxb.java.net

Re: Generating substitution groups in schema

From: Tuomas Kiviaho <tuomas.kiviaho_at_iki.fi>
Date: Wed, 25 Mar 2009 07:28:41 -0700 (PDT)

Wolfgang Laun-2 wrote:
>
> Well, this theoretic discussion won't get us anywhere as I don't clearly
> see what you are trying to achieve. Could you provide an example?
>
I am trying to achieve dynamic element substitution. The example below is
derived from
<http://www.nabble.com/schemagen-and-using-%40XmlElementRef-on-a-non-collection-property-td11532413.html>

public class FilterType extends ProcessorType {

    @XmlElementRef
    private ExpressionType expression;

produced (although I doubt it does anymore since member isn't of parametric
type)
...
        <xs:choice ...>
          <xs:element ref="tns:groovy"/>
          <xs:element ref="tns:ognl"/>
          <xs:element ref="tns:ruby"/>
          <xs:element ref="tns:xpath"/>
        </xs:choice>

but what I'm after is dynamic element substitution like below (and I guess
that the 2.1.10 schemagen also (partially) produces because member isn't of
parametric type)
..
      <xs:element ref="tns:expression" ... />
...
<xs:element name="expressionType" abstract="true" />
<xs:element name="groovy" substitutionGroup="tns:expressionType" />
<xs:element name="ognl substitutionGroup="tns:expressionType" />
<xs:element name="ruby" substitutionGroup="tns:expressionType" />
<xs:element name="xpath" substitutionGroup="tns:expressionType" />


Wolfgang Laun-2 wrote:
>
> Since you are obviously annotating Java classes: what will you be
> needing the generated schema for?
>
I use it only for document validation purposes. JAXB
unmarshalling/marshalling isn't what I'm after. And all of the information
should come from annotations.


Wolfgang Laun-2 wrote:
>
> I don't see the problem with @XmlElements/_at_XmlElement: The
> element's namespace is/can be inherited.
>
In above example the idea is to have dynamic inheritance just like one has
with type substitution. Although the generation in the original was dynamic
the result is static. I can't brind along substitution candidates just by
introducing a new schema to the document


Wolfgang Laun-2 wrote:
>
> In your first email you refer to @XmlElementDecl being connected
> to substitution groups - I think you meant @XmlElementRef?
>
@XmlElementRef indeed. @XmlElementDecl is the one in charge of producing the
global elements and I expected to get the substitutionGroup attributed
global elements to the above example as declared in the following example

@XmlRegistry
public class ObjectParser {

        @XmlElementDecl(name = "groovy", substitutionHeadName = "expressionType")
        public JAXBElement<GroovyExpressionType>
createGroovyExpressionType(GroovyExpressionType expressionType) {
...
        @XmlElementDecl(name = "ongl", substitutionHeadName = "expressionType")
        public JAXBElement<ONGLExpressionType>
createONGLExpressionType(ONGLExpressionType expressionType) {
...
        @XmlElementDecl(name = "ruby", substitutionHeadName = "expressionType")
        public JAXBElement<RubyExpressionType>
createRubyExpressionType(RubyExpressionType expressionType) {
...
        @XmlElementDecl(name = "xpath", substitutionHeadName = "expressionType")
        public JAXBElement<XPathExpressionType>
createXPathExpressionType(XPathExpressionType expressionType) {
 ...
-- 
View this message in context: http://www.nabble.com/Generating-substitution-groups-in-schema-tp22698884p22702865.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.