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); }
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); } }
void saveInheritableAttributes(XSElementDecl currentElemDecl, XMLAttributes attributes) { if (currentElemDecl != null && currentElemDecl.fType instanceof XSComplexTypeDecl) { XSComplexTypeDecl complexTypeDecl = (XSComplexTypeDecl) currentElemDecl.fType; XSObjectListImpl attributeUses = (XSObjectListImpl) complexTypeDecl.getAttributeUses(); // iterate all the attribute declarations of the complex type, for the current element for (int attrUsesIndx = 0; attrUsesIndx < attributeUses.getLength(); attrUsesIndx++) { XSAttributeUse attrUse = (XSAttributeUse) attributeUses.get(attrUsesIndx); if (attrUse.getInheritable()) { // this is an inheritable attribute. copy into an global Vector list. XSAttributeDeclaration attrDecl = (XSAttributeDeclaration) attrUse.getAttrDeclaration(); Augmentations attrAugs = attributes.getAugmentations(attrDecl.getNamespace(), attrDecl.getName()); if (attrAugs != null) { (fXmlSchemaValidator.getInheritableAttrList()).add((AttributePSVI)attrAugs.getItem(Constants.ATTRIBUTE_PSVI)); } } } } } // saveInheritableAttributes
private void expandRelatedAttributeUseComponents(XSAttributeUse component, Vector componentList, String namespace, Hashtable dependencies) { addRelatedAttribute(component.getAttrDeclaration(), componentList, namespace, dependencies); }
private AttributeBinding bindAttribute(XSAttributeUse attrUse) XSAttributeDeclaration attr = attrUse.getAttrDeclaration(); QName attrName = new QName(attr.getNamespace(), attr.getName()); log.trace("binding attribute " + attrName + ", required=" + attrUse.getRequired()); binding.setRequired(attrUse.getRequired()); if(attrUse.getConstraintType() == XSConstants.VC_DEFAULT) binding.setDefaultConstraint(attrUse.getConstraintValue());
public boolean isAttributeRequired() { if(currentAttribute == null) { throw new JBossXBRuntimeException("There is no current attribute!"); } return currentAttribute.getRequired(); }
annotations = ((XSAttributeUse)sourceComponent).getAnnotations(); break; case XSConstants.ATTRIBUTE_GROUP:
private boolean allowsXLink( XSComplexTypeDefinition typeDef ) { XSObjectList xsObjectList = typeDef.getAttributeUses(); for ( int i = 0; i < xsObjectList.getLength(); i++ ) { XSAttributeDeclaration attr = ( (XSAttributeUse) xsObjectList.item( i ) ).getAttrDeclaration(); if ( "href".equals( attr.getName() ) && XLNNS.equals( attr.getNamespace() ) ) { return true; } } return false; }
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()); }
public boolean canHaveRemoteValue() { if (this.type.getTypeCategory() == 14) { return true; } XSComplexTypeDecl complexType = (XSComplexTypeDecl) this.type; XSAttributeGroupDefinition attributeGroupDefinition = complexType .getAttrGrp(); if (attributeGroupDefinition == null) { return false; } XSObjectList attrUses = attributeGroupDefinition.getAttributeUses(); for (int ii = 0; ii < attrUses.getLength(); ii++) { XSAttributeUse attrUse = (XSAttributeUse) attrUses.item(ii); XSAttributeDeclaration attrDecl = attrUse.getAttrDeclaration(); if ((attrDecl.getName().equals("href")) && (attrDecl.getNamespace() != null) && (attrDecl.getNamespace() .equals("http://www.w3.org/1999/xlink"))) { return true; } } return false; }
XSAttributeDeclaration attrDecl = ( (XSAttributeUse) xsdValueType.getAttributeUses().item( i ) ).getAttrDeclaration(); QName name = new QName( attrDecl.getNamespace(), attrDecl.getName() ); attrDecls.put( name, attrDecl ); if ( attrUse.getRequired() ) { XSAttributeDeclaration attrDecl = attrUse.getAttrDeclaration(); QName name = new QName( attrDecl.getNamespace(), attrDecl.getName() ); if ( !attrs.containsKey( name ) ) {
XSAttributeDeclaration decl = use.getAttrDeclaration(); buf.append(write(decl));
XSAttributeUse attribute = ( (XSAttributeUse) attributes.item( i ) ); writer.writeEmptyElement( "attribute" ); writer.writeAttribute( "name", attribute.getAttrDeclaration().getName() ); XSTypeDefinition type = attribute.getAttrDeclaration().getTypeDefinition(); writer.writeAttribute( "type", getPrefixedName( new QName( type.getNamespace(), type.getName() ) ) ); if ( attribute.getRequired() ) { writer.writeAttribute( "use", "required" );
xsAttrUse.getAttrDeclaration().getTypeDefinition(), types))
attrDecls = new HashMap<QName, XSAttributeDeclaration>(); for ( int i = 0; i < xsdValueType.getAttributeUses().getLength(); i++ ) { XSAttributeDeclaration attrDecl = ( (XSAttributeUse) xsdValueType.getAttributeUses().item( i ) ).getAttrDeclaration(); QName name = new QName( attrDecl.getNamespace(), attrDecl.getName() ); attrDecls.put( name, attrDecl ); 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() ); if ( !attrs.containsKey( name ) ) {
xsAttrUse.getAttrDeclaration().getTypeDefinition(), types))
for ( int i = 0; i < attrUses.getLength(); i++ ) { XSAttributeUse attrUse = (XSAttributeUse) attrUses.item( i ); QName attrName = getQName( attrUse.getAttrDeclaration() ); if ( qName.equals( attrName ) ) { return new Pair<PrimitiveType, Boolean>( new PrimitiveType( attrUse.getAttrDeclaration().getTypeDefinition() ), !attrUse.getRequired() );
public static boolean checkComplexType(XSTypeDefinition td) { if (td.getTypeCategory() != XSTypeDefinition.COMPLEX_TYPE) { return false; } XSComplexTypeDefinition ctd = (XSComplexTypeDefinition) td; if (ctd.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_ELEMENT) { return true; } if ((td instanceof XSComplexTypeDecl) && ((XSComplexTypeDecl) td).getAbstract()) { return true; } if (TEXT_ELEMENTS_ARE_COMPLEX) { return true; } if (ctd.getAttributeUses() != null) { for (int i = 0; i < ctd.getAttributeUses().getLength(); i++) { XSSimpleTypeDefinition xsstd = ((XSAttributeUse) ctd.getAttributeUses().item(i)).getAttrDeclaration() .getTypeDefinition(); if ("ID".equals(xsstd.getName())) { continue; } return true; } } return false; }
for ( int i = 0; i < attributeUses.getLength(); i++ ) { XSAttributeUse attrUse = ( (XSAttributeUse) attributeUses.item( i ) ); XSAttributeDeclaration attrDecl = attrUse.getAttrDeclaration(); QName attrName = new QName( attrDecl.getName() ); if ( XLNNS.equals( attrDecl.getNamespace() ) ) { 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 ) );
XSAttributeDeclaration attrDec = currentAttribute.getAttrDeclaration(); String attrNs = attrDec.getNamespace(); String attrLocal = attrDec.getName();