Java源码示例:com.sun.xml.internal.xsom.XSAttributeDecl

示例1
public void attributeUse( XSAttributeUse use ) {
    XSAttributeDecl decl = use.getDecl();

    String additionalAtts="";

    if(use.isRequired())
        additionalAtts += " use=\"required\"";
    if(use.getFixedValue()!=null && use.getDecl().getFixedValue()==null)
        additionalAtts += " fixed=\""+use.getFixedValue()+'\"';
    if(use.getDefaultValue()!=null && use.getDecl().getDefaultValue()==null)
        additionalAtts += " default=\""+use.getDefaultValue()+'\"';

    if(decl.isLocal()) {
        // this is anonymous attribute use
        dump(decl,additionalAtts);
    } else {
        // reference to a global one
        println(MessageFormat.format("<attribute ref=\"'{'{0}'}'{1}{2}\"/>",
            decl.getTargetNamespace(), decl.getName(), additionalAtts));
    }
}
 
示例2
private void dump( XSAttributeDecl decl, String additionalAtts ) {
    XSSimpleType type=decl.getType();

    println(MessageFormat.format("<attribute name=\"{0}\"{1}{2}{3}{4}{5}>",
        decl.getName(),
        additionalAtts,
        type.isLocal()?"":
            MessageFormat.format(" type=\"'{'{0}'}'{1}\"", type.getTargetNamespace(), type.getName()),
        decl.getFixedValue()==null ?
            "":" fixed=\""+decl.getFixedValue()+'\"',
        decl.getDefaultValue()==null ?
            "":" default=\""+decl.getDefaultValue()+'\"',
        type.isLocal()?"":" /"));

    if(type.isLocal()) {
        indent++;
        simpleType(type);
        indent--;
        println("</attribute>");
    }
}
 
示例3
public void attributeUse( XSAttributeUse use ) {
    XSAttributeDecl decl = use.getDecl();

    String additionalAtts="";

    if(use.isRequired())
        additionalAtts += " use=\"required\"";
    if(use.getFixedValue()!=null && use.getDecl().getFixedValue()==null)
        additionalAtts += " fixed=\""+use.getFixedValue()+'\"';
    if(use.getDefaultValue()!=null && use.getDecl().getDefaultValue()==null)
        additionalAtts += " default=\""+use.getDefaultValue()+'\"';

    if(decl.isLocal()) {
        // this is anonymous attribute use
        dump(decl,additionalAtts);
    } else {
        // reference to a global one
        println(MessageFormat.format("<attribute ref=\"'{'{0}'}'{1}{2}\"/>",
            decl.getTargetNamespace(), decl.getName(), additionalAtts));
    }
}
 
示例4
/**
 * Creates node for attribute declaration with additional attributes.
 *
 * @param decl           Attribute declaration.
 * @param additionalAtts Additional attributes.
 */
private void dump(XSAttributeDecl decl, String additionalAtts) {
    XSSimpleType type = decl.getType();

    String str = MessageFormat.format("Attribute \"{0}\"{1}{2}{3}{4}",
            new Object[]{
                decl.getName(),
                additionalAtts,
                type.isLocal() ? "" : MessageFormat.format(
                        " type=\"'{'{0}'}'{1}\"", new Object[]{
                            type.getTargetNamespace(),
                            type.getName()}),
                decl.getFixedValue() == null ? "" : " fixed=\""
            + decl.getFixedValue() + "\"",
                decl.getDefaultValue() == null ? "" : " default=\""
            + decl.getDefaultValue() + "\""});

    SchemaTreeNode newNode = new SchemaTreeNode(str, decl.getLocator());
    this.currNode.add(newNode);
    this.currNode = newNode;

    if (type.isLocal()) {
        simpleType(type);
    }
    this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
 
示例5
public void attributeUse( XSAttributeUse use ) {
    XSAttributeDecl decl = use.getDecl();

    String additionalAtts="";

    if(use.isRequired())
        additionalAtts += " use=\"required\"";
    if(use.getFixedValue()!=null && use.getDecl().getFixedValue()==null)
        additionalAtts += " fixed=\""+use.getFixedValue()+'\"';
    if(use.getDefaultValue()!=null && use.getDecl().getDefaultValue()==null)
        additionalAtts += " default=\""+use.getDefaultValue()+'\"';

    if(decl.isLocal()) {
        // this is anonymous attribute use
        dump(decl,additionalAtts);
    } else {
        // reference to a global one
        println(MessageFormat.format("<attribute ref=\"'{'{0}'}'{1}{2}\"/>",
            decl.getTargetNamespace(), decl.getName(), additionalAtts));
    }
}
 
示例6
private void dump( XSAttributeDecl decl, String additionalAtts ) {
    XSSimpleType type=decl.getType();

    println(MessageFormat.format("<attribute name=\"{0}\"{1}{2}{3}{4}{5}>",
        decl.getName(),
        additionalAtts,
        type.isLocal()?"":
            MessageFormat.format(" type=\"'{'{0}'}'{1}\"", type.getTargetNamespace(), type.getName()),
        decl.getFixedValue()==null ?
            "":" fixed=\""+decl.getFixedValue()+'\"',
        decl.getDefaultValue()==null ?
            "":" default=\""+decl.getDefaultValue()+'\"',
        type.isLocal()?"":" /"));

    if(type.isLocal()) {
        indent++;
        simpleType(type);
        indent--;
        println("</attribute>");
    }
}
 
示例7
/**
 * Creates node for attribute declaration with additional attributes.
 *
 * @param decl           Attribute declaration.
 * @param additionalAtts Additional attributes.
 */
private void dump(XSAttributeDecl decl, String additionalAtts) {
    XSSimpleType type = decl.getType();

    String str = MessageFormat.format("Attribute \"{0}\"{1}{2}{3}{4}",
            new Object[]{
                decl.getName(),
                additionalAtts,
                type.isLocal() ? "" : MessageFormat.format(
                        " type=\"'{'{0}'}'{1}\"", new Object[]{
                            type.getTargetNamespace(),
                            type.getName()}),
                decl.getFixedValue() == null ? "" : " fixed=\""
            + decl.getFixedValue() + "\"",
                decl.getDefaultValue() == null ? "" : " default=\""
            + decl.getDefaultValue() + "\""});

    SchemaTreeNode newNode = new SchemaTreeNode(str, decl.getLocator());
    this.currNode.add(newNode);
    this.currNode = newNode;

    if (type.isLocal()) {
        simpleType(type);
    }
    this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
 
示例8
/**
 * Creates node for attribute declaration with additional attributes.
 *
 * @param decl           Attribute declaration.
 * @param additionalAtts Additional attributes.
 */
private void dump(XSAttributeDecl decl, String additionalAtts) {
    XSSimpleType type = decl.getType();

    String str = MessageFormat.format("Attribute \"{0}\"{1}{2}{3}{4}",
            new Object[]{
                decl.getName(),
                additionalAtts,
                type.isLocal() ? "" : MessageFormat.format(
                        " type=\"'{'{0}'}'{1}\"", new Object[]{
                            type.getTargetNamespace(),
                            type.getName()}),
                decl.getFixedValue() == null ? "" : " fixed=\""
            + decl.getFixedValue() + "\"",
                decl.getDefaultValue() == null ? "" : " default=\""
            + decl.getDefaultValue() + "\""});

    SchemaTreeNode newNode = new SchemaTreeNode(str, decl.getLocator());
    this.currNode.add(newNode);
    this.currNode = newNode;

    if (type.isLocal()) {
        simpleType(type);
    }
    this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
 
示例9
public void attributeUse( XSAttributeUse use ) {
    XSAttributeDecl decl = use.getDecl();

    String additionalAtts="";

    if(use.isRequired())
        additionalAtts += " use=\"required\"";
    if(use.getFixedValue()!=null && use.getDecl().getFixedValue()==null)
        additionalAtts += " fixed=\""+use.getFixedValue()+'\"';
    if(use.getDefaultValue()!=null && use.getDecl().getDefaultValue()==null)
        additionalAtts += " default=\""+use.getDefaultValue()+'\"';

    if(decl.isLocal()) {
        // this is anonymous attribute use
        dump(decl,additionalAtts);
    } else {
        // reference to a global one
        println(MessageFormat.format("<attribute ref=\"'{'{0}'}'{1}{2}\"/>",
            decl.getTargetNamespace(), decl.getName(), additionalAtts));
    }
}
 
示例10
/**
 * Creates node for attribute declaration with additional attributes.
 *
 * @param decl           Attribute declaration.
 * @param additionalAtts Additional attributes.
 */
private void dump(XSAttributeDecl decl, String additionalAtts) {
    XSSimpleType type = decl.getType();

    String str = MessageFormat.format("Attribute \"{0}\"{1}{2}{3}{4}",
            new Object[]{
                decl.getName(),
                additionalAtts,
                type.isLocal() ? "" : MessageFormat.format(
                        " type=\"'{'{0}'}'{1}\"", new Object[]{
                            type.getTargetNamespace(),
                            type.getName()}),
                decl.getFixedValue() == null ? "" : " fixed=\""
            + decl.getFixedValue() + "\"",
                decl.getDefaultValue() == null ? "" : " default=\""
            + decl.getDefaultValue() + "\""});

    SchemaTreeNode newNode = new SchemaTreeNode(str, decl.getLocator());
    this.currNode.add(newNode);
    this.currNode = newNode;

    if (type.isLocal()) {
        simpleType(type);
    }
    this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
 
示例11
public void attributeUse( XSAttributeUse use ) {
    XSAttributeDecl decl = use.getDecl();

    String additionalAtts="";

    if(use.isRequired())
        additionalAtts += " use=\"required\"";
    if(use.getFixedValue()!=null && use.getDecl().getFixedValue()==null)
        additionalAtts += " fixed=\""+use.getFixedValue()+'\"';
    if(use.getDefaultValue()!=null && use.getDecl().getDefaultValue()==null)
        additionalAtts += " default=\""+use.getDefaultValue()+'\"';

    if(decl.isLocal()) {
        // this is anonymous attribute use
        dump(decl,additionalAtts);
    } else {
        // reference to a global one
        println(MessageFormat.format("<attribute ref=\"'{'{0}'}'{1}{2}\"/>",
            decl.getTargetNamespace(), decl.getName(), additionalAtts));
    }
}
 
示例12
public Iterator<XSAttributeUse> iterateAttributeUses() {

        XSComplexType baseType = getBaseType().asComplexType();

        if( baseType==null )    return super.iterateAttributeUses();

        return new Iterators.Union<XSAttributeUse>(
            new Iterators.Filter<XSAttributeUse>(baseType.iterateAttributeUses()) {
                protected boolean matches(XSAttributeUse value) {
                    XSAttributeDecl u = value.getDecl();
                    UName n = new UName(u.getTargetNamespace(),u.getName());
                    return !prohibitedAtts.contains(n);
                }
            },
            super.iterateAttributeUses() );
    }
 
示例13
private TypeUse bindAttDecl(XSAttributeDecl decl) {
    SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class);
    stb.refererStack.push( decl );
    try {
        return stb.build(decl.getType());
    } finally {
        stb.refererStack.pop();
    }
}
 
示例14
private Iterator<XSAttributeDecl> attributeHolder(final XSAttContainer atts) {
    // TODO: check spec. is this correct?
    return new Iterators.Adapter<XSAttributeDecl,XSAttributeUse>(atts.iterateAttributeUses()) {
        protected XSAttributeDecl filter(XSAttributeUse u) {
            return u.getDecl();
        }
    };
}
 
示例15
public void attributeUse(XSAttributeUse use) {
    XSAttributeDecl decl = use.getDecl();

    String additionalAtts = "";

    if (use.isRequired()) {
        additionalAtts += " use=\"required\"";
    }
    if (use.getFixedValue() != null
            && use.getDecl().getFixedValue() == null) {
        additionalAtts += " fixed=\"" + use.getFixedValue() + "\"";
    }
    if (use.getDefaultValue() != null
            && use.getDecl().getDefaultValue() == null) {
        additionalAtts += " default=\"" + use.getDefaultValue() + "\"";
    }

    if (decl.isLocal()) {
        // this is anonymous attribute use
        dump(decl, additionalAtts);
    }
    else {
        // reference to a global one
        String str = MessageFormat.format(
                "Attribute ref \"'{'{0}'}'{1}{2}\"", new Object[]{
                    decl.getTargetNamespace(), decl.getName(),
                    additionalAtts});
        SchemaTreeNode newNode = new SchemaTreeNode(str, decl.getLocator());
        this.currNode.add(newNode);
    }
}
 
示例16
public void attributeUse(XSAttributeUse use) {
    XSAttributeDecl decl = use.getDecl();

    String additionalAtts = "";

    if (use.isRequired()) {
        additionalAtts += " use=\"required\"";
    }
    if (use.getFixedValue() != null
            && use.getDecl().getFixedValue() == null) {
        additionalAtts += " fixed=\"" + use.getFixedValue() + "\"";
    }
    if (use.getDefaultValue() != null
            && use.getDecl().getDefaultValue() == null) {
        additionalAtts += " default=\"" + use.getDefaultValue() + "\"";
    }

    if (decl.isLocal()) {
        // this is anonymous attribute use
        dump(decl, additionalAtts);
    }
    else {
        // reference to a global one
        String str = MessageFormat.format(
                "Attribute ref \"'{'{0}'}'{1}{2}\"", new Object[]{
                    decl.getTargetNamespace(), decl.getName(),
                    additionalAtts});
        SchemaTreeNode newNode = new SchemaTreeNode(str, decl.getLocator());
        this.currNode.add(newNode);
    }
}
 
示例17
/**
 * Transforms the default name produced from XML name
 * by following the customization.
 *
 * This shouldn't be applied to a class name specified
 * by a customization.
 *
 * @param cmp
 *      The schema component from which the default name is derived.
 */
public String mangleClassName( String name, XSComponent cmp ) {
    if( cmp instanceof XSType )
        return nameXmlTransform.typeName.mangle(name);
    if( cmp instanceof XSElementDecl )
        return nameXmlTransform.elementName.mangle(name);
    if( cmp instanceof XSAttributeDecl )
        return nameXmlTransform.attributeName.mangle(name);
    if( cmp instanceof XSModelGroup || cmp instanceof XSModelGroupDecl )
        return nameXmlTransform.modelGroupName.mangle(name);

    // otherwise no modification
    return name;
}
 
示例18
private TypeUse bindAttDecl(XSAttributeDecl decl) {
    SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class);
    stb.refererStack.push( decl );
    try {
        return stb.build(decl.getType());
    } finally {
        stb.refererStack.pop();
    }
}
 
示例19
/**
 * Transforms the default name produced from XML name
 * by following the customization.
 *
 * This shouldn't be applied to a class name specified
 * by a customization.
 *
 * @param cmp
 *      The schema component from which the default name is derived.
 */
public String mangleClassName( String name, XSComponent cmp ) {
    if( cmp instanceof XSType )
        return nameXmlTransform.typeName.mangle(name);
    if( cmp instanceof XSElementDecl )
        return nameXmlTransform.elementName.mangle(name);
    if( cmp instanceof XSAttributeDecl )
        return nameXmlTransform.attributeName.mangle(name);
    if( cmp instanceof XSModelGroup || cmp instanceof XSModelGroupDecl )
        return nameXmlTransform.modelGroupName.mangle(name);

    // otherwise no modification
    return name;
}
 
示例20
public Iterator<XSAttributeDecl> iterateAttributeDecls() {
    return new Iterators.Map<XSAttributeDecl,XSSchema>(iterateSchema()) {
        protected Iterator<XSAttributeDecl> apply(XSSchema u) {
            return u.iterateAttributeDecls();
        }
    };
}
 
示例21
private TypeUse bindAttDecl(XSAttributeDecl decl) {
    SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class);
    stb.refererStack.push( decl );
    try {
        return stb.build(decl.getType());
    } finally {
        stb.refererStack.pop();
    }
}
 
示例22
public void attributeUse(XSAttributeUse use) {
    XSAttributeDecl decl = use.getDecl();

    String additionalAtts = "";

    if (use.isRequired()) {
        additionalAtts += " use=\"required\"";
    }
    if (use.getFixedValue() != null
            && use.getDecl().getFixedValue() == null) {
        additionalAtts += " fixed=\"" + use.getFixedValue() + "\"";
    }
    if (use.getDefaultValue() != null
            && use.getDecl().getDefaultValue() == null) {
        additionalAtts += " default=\"" + use.getDefaultValue() + "\"";
    }

    if (decl.isLocal()) {
        // this is anonymous attribute use
        dump(decl, additionalAtts);
    }
    else {
        // reference to a global one
        String str = MessageFormat.format(
                "Attribute ref \"'{'{0}'}'{1}{2}\"", new Object[]{
                    decl.getTargetNamespace(), decl.getName(),
                    additionalAtts});
        SchemaTreeNode newNode = new SchemaTreeNode(str, decl.getLocator());
        this.currNode.add(newNode);
    }
}
 
示例23
public Iterator<XSAttributeDecl> iterateAttributeDecls() {
    return new Iterators.Map<XSAttributeDecl,XSSchema>(iterateSchema()) {
        protected Iterator<XSAttributeDecl> apply(XSSchema u) {
            return u.iterateAttributeDecls();
        }
    };
}
 
示例24
public void schema( XSSchema s ) {

        // QUICK HACK: don't print the built-in components
        if(s.getTargetNamespace().equals(Const.schemaNamespace))
            return;

        println(MessageFormat.format("<schema targetNamespace=\"{0}\">", s.getTargetNamespace()));
        indent++;

        Iterator itr;

        itr = s.iterateAttGroupDecls();
        while(itr.hasNext())
            attGroupDecl( (XSAttGroupDecl)itr.next() );

        itr = s.iterateAttributeDecls();
        while(itr.hasNext())
            attributeDecl( (XSAttributeDecl)itr.next() );

        itr = s.iterateComplexTypes();
        while(itr.hasNext())
            complexType( (XSComplexType)itr.next() );

        itr = s.iterateElementDecls();
        while(itr.hasNext())
            elementDecl( (XSElementDecl)itr.next() );

        itr = s.iterateModelGroupDecls();
        while(itr.hasNext())
            modelGroupDecl( (XSModelGroupDecl)itr.next() );

        itr = s.iterateSimpleTypes();
        while(itr.hasNext())
            simpleType( (XSSimpleType)itr.next() );

        indent--;
        println("</schema>");
    }
 
示例25
private Iterator<XSAttributeDecl> attributeHolder(final XSAttContainer atts) {
    // TODO: check spec. is this correct?
    return new Iterators.Adapter<XSAttributeDecl,XSAttributeUse>(atts.iterateAttributeUses()) {
        protected XSAttributeDecl filter(XSAttributeUse u) {
            return u.getDecl();
        }
    };
}
 
示例26
public void attributeDecl(XSAttributeDecl xsAttributeDecl) {
    // TODO
    throw new UnsupportedOperationException();
}
 
示例27
public void addAttributeDecl(XSAttributeDecl newDecl) {
    atts.put(newDecl.getName(), newDecl);
}
 
示例28
public Iterator<XSAttributeDecl> attGroupDecl(XSAttGroupDecl decl) {
    return attributeHolder(decl);
}
 
示例29
public XSAttributeDecl getAttributeDecl(String name) {
    return atts.get(name);
}
 
示例30
public XSAttributeDecl getAttributeDecl( String ns, String localName ) {
    XSSchema schema = getSchema(ns);
    if(schema==null)    return null;

    return schema.getAttributeDecl(localName);
}