Refine search
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)); } }
@Override public QName attributeDecl(final XSAttributeDecl decl) { return new QName(decl.getTargetNamespace(), decl.getName()); }
@Override public QName attributeUse(final XSAttributeUse use) { return new QName(use.getDecl().getTargetNamespace(), use.getDecl().getName()); }
// To get ComplexType attributes private static void getComplexAttributes(XSComplexType xsComplexType) { Collection<? extends XSAttributeUse> c = xsComplexType.getAttributeUses(); Iterator<? extends XSAttributeUse> i = c.iterator(); while(i.hasNext()) { // i.next is attributeUse XSAttributeUse attUse = i.next(); System.out.println("Attributes for CoplexType:"+ xsComplexType.getName()); parseAttribute(attUse); } } // To Get attribute info private static void parseAttribute(XSAttributeUse attUse) { XSAttributeDecl attributeDecl = attUse.getDecl(); System.out.println("Attribute Name:"+attributeDecl.getName()); XSSimpleType xsAttributeType = attributeDecl.getType(); System.out.println("Attribute Type: " + xsAttributeType.getName()); if (attUse.isRequired()) System.out.println("Use: Required"); else System.out.println("Use: Optional"); System.out.println("Fixed: " + attributeDecl.getFixedValue()); System.out.println("Default: " + attributeDecl.getDefaultValue()); }
protected void loadAttributes(Schema schema, XSComplexType xsct, ComplexType ct) throws TypeBindingException { Collection<? extends XSAttributeUse> attrs = xsct.getAttributeUses(); for (XSAttributeUse attr : attrs) { XSAttributeDecl at = attr.getDecl(); Type fieldType = loadType(schema, at.getType(), at.getName()); if (fieldType == null) { throw new TypeBindingException("Cannot add type for '" + at.getName() + "'"); } createField(ct, at, fieldType, !attr.isRequired()); } }
public CAttributePropertyInfo createAttributeProperty( XSAttributeUse use, TypeUse tu ) { boolean forConstant = getCustomization(use).isConstantProperty() && use.getFixedValue()!=null; String name = getPropertyName(forConstant); if(name==null) { NameConverter conv = getBuilder().getNameConverter(); if(forConstant) name = conv.toConstantName(use.getDecl().getName()); else name = conv.toPropertyName(use.getDecl().getName()); if(tu.isCollection() && getBuilder().getGlobalBinding().isSimpleMode()) name = JJavaName.getPluralForm(name); } markAsAcknowledged(); constantPropertyErrorCheck(); return wrapUp(new CAttributePropertyInfo(name,use,getCustomizations(use),use.getLocator(), BGMBuilder.getName(use.getDecl()), tu, BGMBuilder.getName(use.getDecl().getType()), use.isRequired() ),use); }
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; } }
private void write(Struct st, XSAttributeDecl decl, boolean goingup) { if (decl.getType().isRestriction() && (decl.getType().getName() == null || !basicTypes .contains(decl.getType().getName()))) { String typeName = processSimpleType(decl.getType(), decl.getName()); st.addField(decl.getName(), typeName, goingup, false, decl.getFixedValue(), xsdMapping); } else if (decl.getType().isList()) { st.addField(decl.getName(), decl.getType().asList().getItemType() .getName(), goingup, true, null, xsdMapping); } else { st.addField(decl.getName(), decl.getType().getName(), goingup, false, decl.getFixedValue(), xsdMapping); } }
public void addAttributeDecl(XSAttributeDecl newDecl) { atts.put(newDecl.getName(), newDecl); } public Map<String,XSAttributeDecl> getAttributeDecls() {
@Override public Boolean attributeUse(final XSAttributeUse use) { return use.getFixedValue() != null || use.getDecl().getFixedValue() != null; }
/** * Determine whether the definition contains "list" attribute (directly or indirectly) */ private boolean isList(XSComplexType complexType) { Collection<? extends XSAttributeUse> attributeUses = complexType.getAttributeUses(); return attributeUses != null && attributeUses.stream() .anyMatch(au -> au.getDecl() != null && DOMUtil.IS_LIST_ATTRIBUTE_NAME.equals(au.getDecl().getName())); }
protected static Field createField(ComplexType type, XSAttributeDecl element, Type fieldType, boolean isNillable) { String elementName = element.getName(); XmlString dv = element.getDefaultValue(); String defValue = null; if (dv != null) { defValue = dv.value; } int flags = 0; if (defValue == null) { dv = element.getFixedValue(); if (dv != null) { defValue = dv.value; flags |= Field.CONSTANT; } } Set<Constraint> constraints = new HashSet<>(); if (!isNillable) { constraints.add(NotNullConstraint.get()); } if (fieldType.isSimpleType()) { constraints.addAll(fieldType.getConstraints()); } return type.addField(elementName, fieldType, defValue, flags, constraints); }
public Boolean attributeDecl(XSAttributeDecl decl) { return decl.getFixedValue()!=null; }
public XmlString getDefaultValue() { if( defaultValue!=null ) return defaultValue; else return getDecl().getDefaultValue(); }
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>"); } }
private void processAttribute(XSAttributeUse attributeUse, ParseContext parseContext) throws Exception { XSAttributeDecl attributeDecl = attributeUse.getDecl(); XSSimpleType xsSimpleType = attributeDecl.getType(); ParseContext attributeContext = new ParseContext(); if (attributeUse.isRequired()){ attributeContext.minOccurs = 1; } else { attributeContext.minOccurs = 0; } attributeContext.currentClass = parseContext.currentClass; attributeContext.maxOccurs = 1; attributeContext.path = parseContext.path + "/@" + attributeDecl.getName(); System.out.print(parseContext.indent + "[Attribute " + attributeContext.path + " " + attributeContext.getOccurs() + "] of type [" + xsSimpleType.getName() + "]"); addSimpleType(attributeDecl.getName(), xsSimpleType, attributeContext, ElementType.ATTRIBUTE); }
public void addAttributeDecl(XSAttributeDecl newDecl) { atts.put(newDecl.getName(), newDecl); } public Map<String,XSAttributeDecl> getAttributeDecls() {