public boolean isAttributeRequired() { if(currentAttribute == null) { throw new JBossXBRuntimeException("There is no current attribute!"); } return currentAttribute.getRequired(); }
private List<Schema.Field> createFields(XSComplexTypeDefinition type) { final Map<String, Schema.Field> fields = new LinkedHashMap<>(); XSObjectList attrUses = type.getAttributeUses(); for (int i = 0; i < attrUses.getLength(); i++) { XSAttributeUse attrUse = (XSAttributeUse) attrUses.item(i); XSAttributeDeclaration attrDecl = attrUse.getAttrDeclaration(); boolean optional = !attrUse.getRequired(); Schema.Field field = createField(fields.values(), attrDecl, attrDecl.getTypeDefinition(), optional, false); fields.put(field.getProp(Source.SOURCE), field); } XSParticle particle = type.getParticle(); if (particle == null) return new ArrayList<>(fields.values()); XSTerm term = particle.getTerm(); if (term.getType() != XSConstants.MODEL_GROUP) throw new ConverterException("Unsupported term type " + term.getType()); XSModelGroup group = (XSModelGroup) term; createGroupFields(group, fields, false); return new ArrayList<>(fields.values()); }
if ( attrUse.getRequired() ) { XSAttributeDeclaration attrDecl = attrUse.getAttrDeclaration(); QName name = new QName( attrDecl.getNamespace(), attrDecl.getName() );
private void processAttribute(Path parent, String path, XSAttributeUse xsAttribute) throws BagriException { path += "/@" + xsAttribute.getAttrDeclaration().getName(); XSSimpleTypeDefinition std = xsAttribute.getAttrDeclaration().getTypeDefinition(); Occurrence occurrence = Occurrence.getOccurrence( xsAttribute.getRequired() ? 1 : 0, std.getVariety() == XSSimpleTypeDefinition.VARIETY_LIST ? -1 : 1); Path xp = modelMgr.translatePath(parent.getRoot(), path, NodeKind.attribute, parent.getPathId(), getBaseType(std), occurrence); logger.trace("processAttribute; attribute: {}; type: {}; got XDMPath: {}", path, std, xp); }
writer.writeAttribute( "type", getPrefixedName( new QName( type.getNamespace(), type.getName() ) ) ); if ( attribute.getRequired() ) { writer.writeAttribute( "use", "required" );
for ( int i = 0; i < xsdValueType.getAttributeUses().getLength(); i++ ) { XSAttributeUse attrUse = (XSAttributeUse) xsdValueType.getAttributeUses().item( i ); if ( attrUse.getRequired() ) { XSAttributeDeclaration attrDecl = attrUse.getAttrDeclaration(); QName name = new QName( attrDecl.getNamespace(), attrDecl.getName() );
DBField dbField = new DBField( attrMc.getTable(), attrMc.getColumn() ); PrimitiveType pt = new PrimitiveType( attrDecl.getTypeDefinition() ); particles.add( new PrimitiveMapping( path, !attrUse.getRequired(), dbField, pt, null, null ) );
for ( int i = 0; i < attrUses.getLength(); i++ ) { XSAttributeUse attrUse = (XSAttributeUse) attrUses.item( i ); if ( attrUse.getRequired() ) { QName attrName = null; XSAttributeDeclaration attrDecl = attrUse.getAttrDeclaration();
new PrimitiveType( attrUse.getAttrDeclaration().getTypeDefinition() ), !attrUse.getRequired() );
DBField dbField = new DBField( attrMc.getTable(), attrMc.getColumn() ); PrimitiveType pt = new PrimitiveType( attrDecl.getTypeDefinition() ); particles.add( new PrimitiveMapping( path, !attrUse.getRequired(), dbField, pt, null, null ) );
log.trace("binding attribute " + attrName + ", required=" + attrUse.getRequired()); binding.setRequired(attrUse.getRequired()); if(attrUse.getConstraintType() == XSConstants.VC_DEFAULT)
null, "null", au.getRequired() ); fd1.tagName = ad.getName();
private void preProcessXSAttributeUse(XSAttributeUse attr) throws Exception { XSAttributeDeclaration decl = attr.getAttrDeclaration(); String sampleValue = null; switch (attr.getConstraintType()) { case XSConstants.VC_FIXED: if (RandomUtil.randomBoolean(config.generateFixedAttributes)) { sampleValue = attr.getValueConstraintValue().getNormalizedValue(); } break; case XSConstants.VC_DEFAULT: if (RandomUtil.randomBoolean(config.generateDefaultAttributes)) { sampleValue = attr.getValueConstraintValue().getNormalizedValue(); } break; default: if (attr.getRequired() || RandomUtil.randomBoolean(config.generateOptionalAttributes)) { if (sampleValue == null) { sampleValue = generateSampleValue(config, decl.getTypeDefinition(), decl.getName(), counters); } } } if (sampleValue != null) { doc.addAttribute(decl.getNamespace(), decl.getName(), sampleValue); } }