private static int XsTypeToMetadataType(XSType xsType) { String name = ""; if (xsType != null) { name = xsType.getName(); } if ("byte".equalsIgnoreCase(name)) { return ProductData.TYPE_UINT8; } else if ("integer".equalsIgnoreCase(name)) { return ProductData.TYPE_INT32; } else if ("double".equalsIgnoreCase(name) || "real".equalsIgnoreCase(name)) { return ProductData.TYPE_FLOAT32; } else if ("date".equals(name) || "dateTime".equals(name)) { return ProductData.TYPE_UTC; } else { return ProductData.TYPE_ASCII; } }
static int XsTypeToMetadataType(XSType xsType) { String name = ""; if (xsType != null) { name = xsType.getName(); } if ("byte".equalsIgnoreCase(name)) { return ProductData.TYPE_UINT8; } else if ("integer".equalsIgnoreCase(name)) { return ProductData.TYPE_INT32; } else if ("double".equalsIgnoreCase(name) || "real".equalsIgnoreCase(name) || "float".equalsIgnoreCase(name)) { return ProductData.TYPE_FLOAT32; } else if ("date".equals(name) || "dateTime".equals(name)) { return ProductData.TYPE_UTC; } else { return ProductData.TYPE_ASCII; } }
protected static String getTypeName(XSType type, String fieldName) { String typeName = type.getName(); if (typeName == null || type.isLocal()) { return getAnonymousTypeName(type, fieldName); } else { return typeName; } }
private Map<QName, List<QName>> getComplexTypeToElementName(ClassOutline classOutline) { Map<QName, List<QName>> complexTypeToElementName = new HashMap<>(); XSSchemaSet schemaSet = classOutline.target.getSchemaComponent().getRoot(); for (XSSchema schema : schemaSet.getSchemas()) { Map<String, XSElementDecl> elemDecls = schema.getElementDecls(); for (Entry<String, XSElementDecl> entry : elemDecls.entrySet()) { XSElementDecl decl = entry.getValue(); XSType xsType = decl.getType(); if (xsType.getName() == null) { continue; } QName type = new QName(xsType.getTargetNamespace(), xsType.getName()); List<QName> qnames = complexTypeToElementName.get(type); if (qnames == null) { qnames = new ArrayList<>(); complexTypeToElementName.put(type, qnames); } qnames.add(new QName(decl.getTargetNamespace(), decl.getName())); } } return complexTypeToElementName; }
public SimpleTypeDefinition createSimpleTypeDefinition(XSSimpleType simpleType, PrismContext prismContext, XSAnnotation annotation) throws SchemaException { QName typeName = new QName(simpleType.getTargetNamespace(), simpleType.getName()); XSType baseType = simpleType.getBaseType(); QName baseTypeName = baseType != null ? new QName(baseType.getTargetNamespace(), baseType.getName()) : null; SimpleTypeDefinition.DerivationMethod derivationMethod; switch (simpleType.getDerivationMethod()) { case XSSimpleType.EXTENSION: derivationMethod = EXTENSION; break; case XSSimpleType.RESTRICTION: derivationMethod = RESTRICTION; break; case XSSimpleType.SUBSTITUTION: derivationMethod = SUBSTITUTION; break; default: derivationMethod = null; // TODO are combinations allowed? e.g. EXTENSION+SUBSTITUTION? } return new SimpleTypeDefinitionImpl(typeName, baseTypeName, derivationMethod, prismContext); }
protected ListType loadListType(Schema schema, XSListSimpleType type, String fieldName) throws TypeBindingException { String name = getTypeName(type, fieldName); XSType xsItemType = type.getItemType(); Type itemType; if (xsItemType.getTargetNamespace().equals(NS_XSD)) { itemType = XSDTypes.getType(xsItemType.getName()); } else { itemType = loadSimpleType(schema, xsItemType, null); } if (itemType == null) { log.error("list item type was not defined -> you should define first the item type"); return null; } return new ListTypeImpl(schema.getName(), name, itemType); }
public static boolean hasAnnotation(XSType xsType, QName annotationElementName) { if (xsType.getName() == null) { return false; } Element annotationElement = getAnnotationElement(xsType.getAnnotation(), annotationElementName); if (annotationElement != null) { return true; } if (xsType.getBaseType() != null && !xsType.getBaseType().equals(xsType)) { return hasAnnotation(xsType.getBaseType(), annotationElementName); } return false; }
public void run() throws SAXException { XSType t = baseType.getType(); if (t.isComplexType() && t.asComplexType().getContentType().asParticle()!=null) { $runtime.reportError( Messages.format(Messages.ERR_SIMPLE_CONTENT_EXPECTED, t.getTargetNamespace(), t.getName()), loc); } } });
public void run() throws SAXException { XSType t = baseType.getType(); if (t.isComplexType() && t.asComplexType().getContentType().asParticle()!=null) { $runtime.reportError( Messages.format(Messages.ERR_SIMPLE_CONTENT_EXPECTED, t.getTargetNamespace(), t.getName()), loc); } } });
public void run() throws SAXException { XSType t = baseType.getType(); if (t.isComplexType() && t.asComplexType().getContentType().asParticle()!=null) { $runtime.reportError( Messages.format(Messages.ERR_SIMPLE_CONTENT_EXPECTED, t.getTargetNamespace(), t.getName()), loc); } } });
public void run() throws SAXException { XSType t = baseType.getType(); if (t.isComplexType() && t.asComplexType().getContentType().asParticle()!=null) { $runtime.reportError( Messages.format(Messages.ERR_SIMPLE_CONTENT_EXPECTED, t.getTargetNamespace(), t.getName()), loc); } } });
public void run() throws SAXException { XSType t = baseType.getType(); if (t.isComplexType() && t.asComplexType().getContentType().asParticle()!=null) { $runtime.reportError( Messages.format(Messages.ERR_SIMPLE_CONTENT_EXPECTED, t.getTargetNamespace(), t.getName()), loc); } } });
/** * Creates node for element declaration with additional attributes. * * @param decl Element declaration. * @param extraAtts Additional attributes. */ private void elementDecl(XSElementDecl decl, String extraAtts) { XSType type = decl.getType(); // TODO: various other attributes String str = MessageFormat.format("Element name=\"{0}\"{1}{2}", new Object[]{ decl.getName(), type.isLocal() ? "" : " type=\"{" + type.getTargetNamespace() + "}" + type.getName() + "\"", extraAtts}); SchemaTreeNode newNode = new SchemaTreeNode(str, decl.getLocator()); this.currNode.add(newNode); this.currNode = newNode; if (type.isLocal()) { if (type.isLocal()) { type.visit(this); } } this.currNode = (SchemaTreeNode) this.currNode.getParent(); }
private void elementDecl( XSElementDecl decl, String extraAtts ) { XSType type = decl.getType(); // TODO: various other attributes // qualified attr; Issue if(decl.getForm() != null) { extraAtts += " form=\"" + (decl.getForm() ? "qualified" : "unqualified" ) + "\""; } println(MessageFormat.format("<element name=\"{0}\"{1}{2}{3}>", decl.getName(), type.isLocal()?"":" type=\"{"+ type.getTargetNamespace()+'}'+ type.getName()+'\"', extraAtts, type.isLocal()?"":"/")); if(type.isLocal()) { indent++; if(type.isLocal()) type.visit(this); indent--; println("</element>"); } }
private void elementDecl( XSElementDecl decl, String extraAtts ) { XSType type = decl.getType(); // TODO: various other attributes // qualified attr; Issue if(decl.getForm() != null) { extraAtts += " form=\"" + (decl.getForm() ? "qualified" : "unqualified" ) + "\""; } println(MessageFormat.format("<element name=\"{0}\"{1}{2}{3}>", decl.getName(), type.isLocal()?"":" type=\"{"+ type.getTargetNamespace()+'}'+ type.getName()+'\"', extraAtts, type.isLocal()?"":"/")); if(type.isLocal()) { indent++; if(type.isLocal()) type.visit(this); indent--; println("</element>"); } }
private void elementDecl( XSElementDecl decl, String extraAtts ) { XSType type = decl.getType(); // TODO: various other attributes // qualified attr; Issue if(decl.getForm() != null) { extraAtts += " form=\"" + (decl.getForm() ? "qualified" : "unqualified" ) + "\""; } println(MessageFormat.format("<element name=\"{0}\"{1}{2}{3}>", decl.getName(), type.isLocal()?"":" type=\"{"+ type.getTargetNamespace()+'}'+ type.getName()+'\"', extraAtts, type.isLocal()?"":"/")); if(type.isLocal()) { indent++; if(type.isLocal()) type.visit(this); indent--; println("</element>"); } }
private void elementDecl( XSElementDecl decl, String extraAtts ) { XSType type = decl.getType(); // TODO: various other attributes // qualified attr; Issue if(decl.getForm() != null) { extraAtts += " form=\"" + (decl.getForm() ? "qualified" : "unqualified" ) + "\""; } println(MessageFormat.format("<element name=\"{0}\"{1}{2}{3}>", decl.getName(), type.isLocal()?"":" type=\"{"+ type.getTargetNamespace()+'}'+ type.getName()+'\"', extraAtts, type.isLocal()?"":"/")); if(type.isLocal()) { indent++; if(type.isLocal()) type.visit(this); indent--; println("</element>"); } }