com.sun.xml.xsom.XSAttributeDecl Java Examples

The following examples show how to use com.sun.xml.xsom.XSAttributeDecl. 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: XmlFormBuilder.java    From dynaform with Artistic License 2.0 6 votes vote down vote up
public XmlForm attributeUse(XSAttributeUse use) {
  boolean required = use.isRequired();
  
  if (log.isDebugEnabled())
    log.debug("Attribute Use: " + use +
        ", Required: " + required);
  
  XSAttributeDecl decl = use.getDecl();

  XmlForm xmlForm = decl.apply(this);

  if (required) {
    Form form = xmlForm.getForm();
    if (form instanceof FormElement<?>)
      ((FormElement<?>) form).setRequired(true);
  }
  
  return xmlForm;
}
 
Example #2
Source File: ComplexTypeImpl.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
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() );
}
 
Example #3
Source File: JumbuneSchemaWriter.java    From jumbune with GNU Lesser General Public License v3.0 6 votes vote down vote up
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));
    }
}
 
Example #4
Source File: SchemaWriter.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
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}\"/>",
            new Object[]{ decl.getTargetNamespace(), decl.getName(),
                additionalAtts }));
    }
}
 
Example #5
Source File: JumbuneSchemaWriter.java    From jumbune with GNU Lesser General Public License v3.0 6 votes vote down vote up
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>");
    }
}
 
Example #6
Source File: SchemaTreeTraverser.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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();
}
 
Example #7
Source File: SchemaWriter.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
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>");
	}
}
 
Example #8
Source File: SchemaWriter.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
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));
	}
}
 
Example #9
Source File: MetaPlugin.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
@Override
public QName attributeDecl(final XSAttributeDecl decl) {
	if (decl.getType().getName() == null) {
		return new QName(decl.getType().getTargetNamespace(), "anonymousAttributeType");
	} else {
		return new QName(decl.getType().getTargetNamespace(), decl.getType().getName());
	}
}
 
Example #10
Source File: XmlFormBuilder.java    From dynaform with Artistic License 2.0 5 votes vote down vote up
private void attributes(List<Form> forms,
    Map<String, TextWriter> attrWriters,
    Map<String, TextHandler> attrReaders,
    Collection<? extends XSAttributeUse> attrs) {
  
  for (XSAttributeUse use : attrs) {
    XmlForm xmlForm = use.apply(this);
    if (xmlForm != null) {
      XSAttributeDecl attr = use.getDecl();
      String name = attr.getName();

      Form form = xmlForm.getForm();
      if (form != null)
        forms.add(form);

      XmlWriter writer = xmlForm.getWriter();
      if (writer instanceof TextXmlWriter) {
        TextWriter textWriter = ((TextXmlWriter) writer).getWriter();
        attrWriters.put(name, textWriter);
      }
      
      XmlReader reader = xmlForm.getReader();
      TextHandler handler = null;
      if (reader instanceof TextXmlReader) {
        TextXmlReader textXmlReader = (TextXmlReader) reader;
        handler = textXmlReader.getHandler();
      } else if (reader != null)
        throw new IllegalStateException("XmlReader " + reader + " cannot be assigned to an XML attribtue, TextXmlReader expected");
      if (handler != null)
        attrReaders.put(name, handler);
    }
  }
}
 
Example #11
Source File: SchemaWriter.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void dump( XSAttributeDecl decl, String additionalAtts ) {
    XSSimpleType type=decl.getType();

    println(MessageFormat.format("<attribute name=\"{0}\"{1}{2}{3}{4}{5}>",
        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()+'\"',
            type.isLocal()?"":" /"
        }));

    if(type.isLocal()) {
        indent++;
        simpleType(type);
        indent--;
        println("</attribute>");
    }
}
 
Example #12
Source File: XmlFormBuilder.java    From dynaform with Artistic License 2.0 5 votes vote down vote up
public XmlForm attributeDecl(XSAttributeDecl decl) {
  if (log.isDebugEnabled())
    log.debug("Attribute Declaration: " + decl);
  
  FormElement element = declSimple(decl.getType(), decl.getName(), decl.getDefaultValue(), decl.getFixedValue());
  if (element == null)
    return null;
  
  XmlWriter writer = new TextXmlWriter(new FormElementWriter(element));
  XmlReader reader = new TextXmlReader(new FormElementHandler(element));

  return new XmlFormImpl(element, writer, reader);
}
 
Example #13
Source File: SchemaTreeTraverser.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
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);
    }
}
 
Example #14
Source File: SchemaTreeTraverser.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void schema(XSSchema s) {
    // QUICK HACK: don't print the built-in components
    if (s.getTargetNamespace().equals(Const.schemaNamespace)) {
        return;
    }

    SchemaTreeNode newNode = new SchemaTreeNode("Schema "
            + s.getLocator().getSystemId(), s.getLocator());
    this.currNode = newNode;
    this.model.addSchemaNode(newNode);

    for (XSAttGroupDecl groupDecl : s.getAttGroupDecls().values()) {
        attGroupDecl(groupDecl);
    }

    for (XSAttributeDecl attrDecl : s.getAttributeDecls().values()) {
        attributeDecl(attrDecl);
    }

    for (XSComplexType complexType : s.getComplexTypes().values()) {
        complexType(complexType);
    }

    for (XSElementDecl elementDecl : s.getElementDecls().values()) {
        elementDecl(elementDecl);
    }

    for (XSModelGroupDecl modelGroupDecl : s.getModelGroupDecls().values()) {
        modelGroupDecl(modelGroupDecl);
    }

    for (XSSimpleType simpleType : s.getSimpleTypes().values()) {
        simpleType(simpleType);
    }
}
 
Example #15
Source File: MetaPlugin.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
private String getConstantName(final FieldOutline fieldOutline) {
	final XSComponent schemaComponent = fieldOutline.getPropertyInfo().getSchemaComponent();
	if (!this.fixedAttributeAsConstantProperty) return null;
	if (schemaComponent instanceof XSAttributeDecl) {
		return ((XSAttributeDecl)schemaComponent).getFixedValue() != null ? fieldOutline.parent().parent().getModel().getNameConverter().toConstantName(((XSAttributeDecl)schemaComponent).getName()) : null;
	} else {
		return schemaComponent instanceof XSAttributeUse && ((XSAttributeUse)schemaComponent).getFixedValue() != null ? fieldOutline.parent().parent().getModel().getNameConverter().toConstantName(((XSAttributeUse)schemaComponent).getDecl().getName()) : null;
	}
}
 
Example #16
Source File: Axis.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
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();
        }
    };
}
 
Example #17
Source File: SchemaSetImpl.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Iterator<XSAttributeDecl> iterateAttributeDecls() {
    return new Iterators.Map<XSAttributeDecl,XSSchema>(iterateSchema()) {
        protected Iterator<XSAttributeDecl> apply(XSSchema u) {
            return u.iterateAttributeDecls();
        }
    };
}
 
Example #18
Source File: SchemaWriter.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
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>");
	}
 
Example #19
Source File: Axis.java    From jolie with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Iterator<XSAttributeDecl> complexType(XSComplexType type) {
    return attributeHolder(type);
}
 
Example #20
Source File: SimpleTypeVisitor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void attributeDecl(XSAttributeDecl decl) {
	decl.getType().visit(this);
}
 
Example #21
Source File: JumbuneSchemaWriter.java    From jumbune with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void schema( XSSchema s) {
	
	if(this.elementsMap.size() != 0){

	StringBuffer sb = new StringBuffer();
     
     for(String prefix : uriMapping.keySet()){
    	 
    	 String uri = uriMapping.get(prefix);
    	 if(Const.schemaNamespace.equalsIgnoreCase(uri)) rootPrefix = prefix+":";
    	 sb.append("xmlns:"+prefix+"=\""+uri+"\" " );
    	 
     }
     
     if(!s.getTargetNamespace().isEmpty()){
    	 println(MessageFormat.format("<schema {0} targetNamespace=\"{1}\">",sb.toString(),s.getTargetNamespace()));
     }else{
    	 println(MessageFormat.format("<schema {0} >",sb.toString()));
     }
     
      indent++;

      Iterator<XSAttGroupDecl> itrAGD = s.iterateAttGroupDecls();
      while (itrAGD.hasNext()) {
    	  attGroupDecl(itrAGD.next());
      }

      Iterator<XSAttributeDecl> itrAD = s.iterateAttributeDecls();
      while(itrAD.hasNext()) {
    	  attributeDecl(itrAD.next());
      }

      Iterator<XSComplexType> itrCT = s.iterateComplexTypes();
      while(itrCT.hasNext()) {
    	  complexType(itrCT.next());
      }
      
      Iterator<XSElementDecl> itrED = s.iterateElementDecls();
      while(itrED.hasNext()) {
    	  elementDecl(itrED.next());
      } 
      
      Iterator<XSModelGroupDecl> itrMGD = s.iterateModelGroupDecls();
      while(itrMGD.hasNext()) {
    	  modelGroupDecl(itrMGD.next()); 
      }

      Iterator<XSSimpleType> itrST = s.iterateSimpleTypes();
      while(itrST.hasNext()) {
    	  simpleType(itrST.next());
      }

      indent--;
      println("</schema>");
	}
	//}

   
}
 
Example #22
Source File: FindXSElementDeclVisitor.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void attributeDecl(XSAttributeDecl decl) {
}
 
Example #23
Source File: DefaultFunctionImpl.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public T attributeDecl(XSAttributeDecl decl) {
	return defaultValue(decl);
}
 
Example #24
Source File: JumbuneSchemaWriter.java    From jumbune with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void attributeDecl( XSAttributeDecl decl ) {
    dump(decl,"");
}
 
Example #25
Source File: SchemaWriter.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public void attributeDecl( XSAttributeDecl decl ) {
	dump(decl,"");
}
 
Example #26
Source File: GroupInterfaceGenerator.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
@Override
public Boolean attributeDecl(final XSAttributeDecl decl) {
	return decl.getFixedValue() != null;
}
 
Example #27
Source File: GroupInterfaceGenerator.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
@Override
public String attributeDecl(final XSAttributeDecl decl) {
	final String customName = getCustomPropertyName(decl);
	return customName == null ? GroupInterfaceGenerator.this.pluginContext.outline.getModel().getNameConverter().toPropertyName(decl.getName()) : customName;
}
 
Example #28
Source File: MetaPlugin.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
@Override
public QName attributeDecl(final XSAttributeDecl decl) {
	return new QName(decl.getTargetNamespace(), decl.getName());
}
 
Example #29
Source File: MetaPlugin.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
@Override
public Boolean attributeDecl(final XSAttributeDecl decl) {
	return true;
}
 
Example #30
Source File: CollectEnumerationValuesVisitor.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void attributeDecl(XSAttributeDecl decl) {
	decl.getType().visit((XSSimpleTypeVisitor) this);
}