[xsd-users] ##any type problems

Bradley Beddoes beddoes at intient.com
Wed Dec 20 06:50:30 EST 2006


Hi Boris,

Boris Kolpackov wrote:
> Hi Bradley,
> 
> I've CC'ed xsd-users to my reply; some of the information below
> could be useful to others.
> 
> Bradley Beddoes <beddoes at intient.com> writes:
> 
>> Linux 64bit Fedora and 32bit Fedora is the development environment which
>>  would be good for now, further down the track we will need a larger
>> range of OS's perhaps (Windows/OSX).
> 
> The fix will be part of the upcoming (beginning of Jan) 2.3.1 and thus
> supported on all platforms. What is the platform you are using for
> code generation right now?
> 

Linux 32bit is all I need for the immediate future to continue dev work 
on this side.

> 
>>> I looked into PSVI today but could not find a way to determine if an
>>> element was matched by a wildcard. I am still going to ask on the
>>> Xerces-C++ mailing list.
>> I will be interested to know the outcome of this for my own work with
>> xerces actually.
> 
> I sent an email to the Xerces-C++ mailing list but there is no reply
> yet. I am, however, pretty sure there is no way to obtain the
> necessary information based on my studying of how things work. I am
> going to change the error to a warning for now.
> 
> 
>>> BTW, out of curiosity I checked how this is supported in other data
>>> binding tools. I particularly looking into XMLBeans and, guess what,
>>> it silently generates broken code.
>> Broken how?
> 
> Here is a simple test schema:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
> 
>   <complexType name="Type">
>     <sequence>
>       <element name="foo" type="string" minOccurs="0"/>
>       <element name="bar" type="string"/>
>       <any namespace="##any"/>
>     </sequence>
>   </complexType>
> 
> </schema>
> 
> XMLBeans generates a number of functions for each element, one of which is
> isSetFoo. Here is its implementation:
> 
> public boolean isSetFoo()
>     {
>         synchronized (monitor())
>         {
>             check_orphaned();
>             return get_store().count_elements(FOO$0) != 0;
>         }
>     }
> 
> Where FOO$0 is a QName for the "foo" element. Now imagine an instance
> which omits the first "foo" element but has "foo" in place of the
> wildcard.

I assume you mean the exact same foo (ns/type etc) element here, I would 
actually expect the above to return true, from an instance document is 
it ever important if the element is meant to map to the explict 
definition or the any statement in the schema? probably not... all you 
want to know is that it is there for consumption in your app.

> 
> 
> 
>> The JAXB bindings generator actually creates a member variable of type
>> org.w3c.dom.Element which you can see in the attached source code.
> 
> I think you forgot to attach the code. Hopefully the example with
> XMLBeans will help you check whether JAXB can handle this properly.
> If it does, then it would be interesting to know how.
> 

Not sure what is going on with my mail client lately it seems to be 
broken with attachments at times, anyways assuming this attachment works 
you can see how the ArtifactResponse and StatusResponseTypes are 
generated. I would have to test how your case above would work out but 
my theory is that JAXB would always unmarshall an instance document with 
a single "foo" element as being the value of set/get foo (as it should), 
with subsequent foo elements which are substituted for ##any being 
stored at as set/get any

> 
>> This
>> obviously means that you need to create a second JAXB unmarshaller
>> instance to deal with the types of element you reasonably expect to
>> receive as the any element in your instance documents. We have had the
>> same situation elsewhere with JAXB handling the any type however and it
>> does not pose to much of an issue.
> 
> You can do the same in XSD with the DOM association feature. If you pass
> the keep_dom flag to one of the parsing function, then you can obtain
> the corresponding DOM node for any C++/Tree node and use that to parse
> things further.

Good to know that similar functionality exists in XSD.

> 
> 
> hth,
> -boris


-- 
Bradley Beddoes
Lead Software Architect

Intient - "Open Source, Open Standards"
-------------- next part --------------
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.1-b01-EA1 
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2006.12.20 at 09:39:30 AM EST 
//


package com.qut.middleware.saml2.schemas.protocol;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.w3c.dom.Element;


/**
 * <p>Java class for ArtifactResponseType complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="ArtifactResponseType">
 *   &lt;complexContent>
 *     &lt;extension base="{urn:oasis:names:tc:SAML:2.0:protocol}StatusResponseType">
 *       &lt;sequence>
 *         &lt;any/>
 *       &lt;/sequence>
 *     &lt;/extension>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ArtifactResponseType", propOrder = {
    "any"
})
@XmlRootElement(name = "ArtifactResponse")
public class ArtifactResponse
    extends StatusResponseType
{

    @XmlAnyElement
    protected Element any;

    /**
     * Gets the value of the any property.
     * 
     * @return
     *     possible object is
     *     {@link Element }
     *     
     */
    public Element getAny() {
        return any;
    }

    /**
     * Sets the value of the any property.
     * 
     * @param value
     *     allowed object is
     *     {@link Element }
     *     
     */
    public void setAny(Element value) {
        this.any = value;
    }

}
-------------- next part --------------
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.1-b01-EA1 
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2006.12.20 at 09:39:30 AM EST 
//


package com.qut.middleware.saml2.schemas.protocol;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.datatype.XMLGregorianCalendar;
import com.qut.middleware.saml2.schemas.assertion.NameIDType;
import com.qut.middleware.saml2.schemas.esoe.protocol.ClearAuthzCacheResponse;
import com.qut.middleware.saml2.schemas.esoe.protocol.ValidateInitializationResponse;
import org.w3._2000._09.xmldsig_.Signature;


/**
 * <p>Java class for StatusResponseType complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="StatusResponseType">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element ref="{urn:oasis:names:tc:SAML:2.0:assertion}Issuer" minOccurs="0"/>
 *         &lt;element ref="{http://www.w3.org/2000/09/xmldsig#}Signature" minOccurs="0"/>
 *         &lt;element ref="{urn:oasis:names:tc:SAML:2.0:protocol}Extensions" minOccurs="0"/>
 *         &lt;element ref="{urn:oasis:names:tc:SAML:2.0:protocol}Status"/>
 *       &lt;/sequence>
 *       &lt;attribute name="Consent" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
 *       &lt;attribute name="Destination" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
 *       &lt;attribute name="ID" use="required" type="{http://www.w3.org/2001/XMLSchema}ID" />
 *       &lt;attribute name="InResponseTo" type="{http://www.w3.org/2001/XMLSchema}NCName" />
 *       &lt;attribute name="IssueInstant" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
 *       &lt;attribute name="Version" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "StatusResponseType", propOrder = {
    "issuer",
    "signature",
    "extensions",
    "status"
})
@XmlSeeAlso({
    ValidateInitializationResponse.class,
    ClearAuthzCacheResponse.class,
    NameIDMappingResponse.class,
    Response.class,
    ArtifactResponse.class
})
public class StatusResponseType {

    @XmlElement(name = "Issuer", namespace = "urn:oasis:names:tc:SAML:2.0:assertion")
    protected NameIDType issuer;
    @XmlElement(name = "Signature", namespace = "http://www.w3.org/2000/09/xmldsig#")
    protected Signature signature;
    @XmlElement(name = "Extensions")
    protected Extensions extensions;
    @XmlElement(name = "Status", required = true)
    protected Status status;
    @XmlAttribute(name = "Consent")
    @XmlSchemaType(name = "anyURI")
    protected String consent;
    @XmlAttribute(name = "Destination")
    @XmlSchemaType(name = "anyURI")
    protected String destination;
    @XmlAttribute(name = "ID", required = true)
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlID
    @XmlSchemaType(name = "ID")
    protected String id;
    @XmlAttribute(name = "InResponseTo")
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlSchemaType(name = "NCName")
    protected String inResponseTo;
    @XmlAttribute(name = "IssueInstant", required = true)
    protected XMLGregorianCalendar issueInstant;
    @XmlAttribute(name = "Version", required = true)
    protected String version;

    /**
     * Gets the value of the issuer property.
     * 
     * @return
     *     possible object is
     *     {@link NameIDType }
     *     
     */
    public NameIDType getIssuer() {
        return issuer;
    }

    /**
     * Sets the value of the issuer property.
     * 
     * @param value
     *     allowed object is
     *     {@link NameIDType }
     *     
     */
    public void setIssuer(NameIDType value) {
        this.issuer = value;
    }

    /**
     * Gets the value of the signature property.
     * 
     * @return
     *     possible object is
     *     {@link Signature }
     *     
     */
    public Signature getSignature() {
        return signature;
    }

    /**
     * Sets the value of the signature property.
     * 
     * @param value
     *     allowed object is
     *     {@link Signature }
     *     
     */
    public void setSignature(Signature value) {
        this.signature = value;
    }

    /**
     * Gets the value of the extensions property.
     * 
     * @return
     *     possible object is
     *     {@link Extensions }
     *     
     */
    public Extensions getExtensions() {
        return extensions;
    }

    /**
     * Sets the value of the extensions property.
     * 
     * @param value
     *     allowed object is
     *     {@link Extensions }
     *     
     */
    public void setExtensions(Extensions value) {
        this.extensions = value;
    }

    /**
     * Gets the value of the status property.
     * 
     * @return
     *     possible object is
     *     {@link Status }
     *     
     */
    public Status getStatus() {
        return status;
    }

    /**
     * Sets the value of the status property.
     * 
     * @param value
     *     allowed object is
     *     {@link Status }
     *     
     */
    public void setStatus(Status value) {
        this.status = value;
    }

    /**
     * Gets the value of the consent property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getConsent() {
        return consent;
    }

    /**
     * Sets the value of the consent property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setConsent(String value) {
        this.consent = value;
    }

    /**
     * Gets the value of the destination property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getDestination() {
        return destination;
    }

    /**
     * Sets the value of the destination property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setDestination(String value) {
        this.destination = value;
    }

    /**
     * Gets the value of the id property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getID() {
        return id;
    }

    /**
     * Sets the value of the id property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setID(String value) {
        this.id = value;
    }

    /**
     * Gets the value of the inResponseTo property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getInResponseTo() {
        return inResponseTo;
    }

    /**
     * Sets the value of the inResponseTo property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setInResponseTo(String value) {
        this.inResponseTo = value;
    }

    /**
     * Gets the value of the issueInstant property.
     * 
     * @return
     *     possible object is
     *     {@link XMLGregorianCalendar }
     *     
     */
    public XMLGregorianCalendar getIssueInstant() {
        return issueInstant;
    }

    /**
     * Sets the value of the issueInstant property.
     * 
     * @param value
     *     allowed object is
     *     {@link XMLGregorianCalendar }
     *     
     */
    public void setIssueInstant(XMLGregorianCalendar value) {
        this.issueInstant = value;
    }

    /**
     * Gets the value of the version property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getVersion() {
        return version;
    }

    /**
     * Sets the value of the version property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setVersion(String value) {
        this.version = value;
    }

}


More information about the xsd-users mailing list