Java Code Examples for org.apache.ws.commons.schema.XmlSchemaElement#isNillable()

The following examples show how to use org.apache.ws.commons.schema.XmlSchemaElement#isNillable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParticleInfo.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Create element information for a part element. For a part, the JavaScript
 * and Element names are calculated in advance, and the element itself might
 * be null! In that case, the minOccurs and maxOccurs are conventional. Note
 * that in some cases the code in ServiceJavascriptBuilder uses a local
 * element (or xa:any) from inside the part element, instead of the part
 * element itself.
 *
 * @param element the element, or null
 * @param schemaCollection the schema collection, for resolving types.
 * @param javascriptName javascript variable name
 * @param xmlElementName xml element string
 * @return
 */
public static ParticleInfo forPartElement(XmlSchemaElement element, SchemaCollection schemaCollection,
                                          String javascriptName, String xmlElementName) {
    ParticleInfo elementInfo = new ParticleInfo();
    elementInfo.particle = element;
    if (element == null) {
        elementInfo.minOccurs = 1;
        elementInfo.maxOccurs = 1;
    } else {
        elementInfo.minOccurs = element.getMinOccurs();
        elementInfo.maxOccurs = element.getMaxOccurs();
        elementInfo.nillable = element.isNillable();
        factorySetupType(element, schemaCollection, elementInfo);
    }
    elementInfo.javascriptName = javascriptName;
    elementInfo.xmlName = xmlElementName;
    elementInfo.global = true;

    return elementInfo;
}
 
Example 2
Source File: DataWriterImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean needToRender(MessagePartInfo part) {
    if (part != null && part.getXmlSchema() instanceof XmlSchemaElement) {
        XmlSchemaElement element = (XmlSchemaElement)part.getXmlSchema();
        return element.isNillable() && element.getMinOccurs() > 0;
    }
    return false;
}
 
Example 3
Source File: ParticleInfo.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Create an elementInfo that stores information about a global, named,
 * element.
 *
 * @param element the element
 * @param currentSchema the schema it came from.
 * @param schemaCollection the collection of all schemas.
 * @param prefixAccumulator the accumulator that assigns prefixes.
 * @return
 */
public static ParticleInfo forGlobalElement(XmlSchemaElement element, XmlSchema currentSchema,
                                            SchemaCollection schemaCollection,
                                            NamespacePrefixAccumulator prefixAccumulator) {
    ParticleInfo elementInfo = new ParticleInfo();
    elementInfo.particle = element;
    elementInfo.minOccurs = element.getMinOccurs();
    elementInfo.maxOccurs = element.getMaxOccurs();
    elementInfo.nillable = element.isNillable();
    elementInfo.global = true;

    factoryCommon(element, currentSchema, schemaCollection, prefixAccumulator, elementInfo);
    return elementInfo;
}
 
Example 4
Source File: CommonsSchemaInfoBuilder.java    From tomee with Apache License 2.0 5 votes vote down vote up
private static XmlElementInfo createXmlElementInfo(QName qname, QName xmlType, XmlSchemaElement element) {
    XmlElementInfo elementInfo = new XmlElementInfo();

    elementInfo.qname = qname;
    elementInfo.xmlType = xmlType;
    elementInfo.minOccurs = element.getMinOccurs();
    elementInfo.maxOccurs = element.getMaxOccurs();
    elementInfo.nillable = element.isNillable();

    return elementInfo;
}