Tabnine Logo
XmlSchema
Code IndexAdd Tabnine to your IDE (free)

How to use
XmlSchema
in
org.apache.ws.commons.schema

Best Java code snippets using org.apache.ws.commons.schema.XmlSchema (Showing top 20 results out of 567)

Refine searchRefine arrow

  • QName
  • Element
  • SchemaInfo
  • SchemaCollection
  • XmlSchemaElement
  • ServiceInfo
origin: apache/cxf

public XmlSchema getSchemaForElement(QName name) {
  for (XmlSchema schema : schemaCollection.getXmlSchemas()) {
    if (name.getNamespaceURI().equals(schema.getTargetNamespace())) {
      if (schema.getElementByName(name.getLocalPart()) != null) {
        return schema;
      } else if (schema.getElementByName(name) != null) {
        return schema;
      }
    }
  }
  return null;
}
origin: apache/cxf

  @Override
  public void write(StringBuilder sb) {
    for (XmlSchema xs : coll.getXmlSchemas()) {
      if (xs.getItems().isEmpty() || Constants.URI_2001_SCHEMA_XSD.equals(xs.getTargetNamespace())) {
        continue;
      }
      StringWriter writer = new StringWriter();
      xs.write(writer);
      sb.append(writer.toString());
    }
  }
}
origin: apache/cxf

private void addSchema(Map<String, EmbeddedSchema> sources, XmlSchema schema, Element element)
    throws XMLStreamException {
  String schemaSystemId = schema.getSourceURI();
  if (null == schemaSystemId) {
    schemaSystemId = schema.getTargetNamespace();
  }
  EmbeddedSchema embeddedSchema = new EmbeddedSchema(schemaSystemId, element);
  sources.put(schema.getTargetNamespace(), embeddedSchema);
}
origin: org.apache.ws.commons.schema/XmlSchema

/**
 * Search this schema for a type by qname.
 * @param name
 * @return the type.
 */
public XmlSchemaType getTypeByName(String name) {
  QName nameToSearchFor = new QName(this.getTargetNamespace(),name);
  return getTypeByName(nameToSearchFor, false, null);
}
origin: org.apache.cxf/cxf-api

public XmlSchemaElement getElementByQName(QName qname) {
  String uri = qname.getNamespaceURI();
  if (schema != null
    && schema.getTargetNamespace() != null
    && schema.getTargetNamespace().equals(uri)) {
    return schema.getElementByName(qname);
  }
  return null;
}
origin: org.apache.ws.commons.schema/XmlSchema

private XmlSchemaGroup handleGroup(XmlSchema schema, Element groupEl,
    Element schemaEl) {
  XmlSchemaGroup group = new XmlSchemaGroup();
  group.name = new QName(schema.getTargetNamespace(), groupEl
      .getAttribute("name"));
  for (Element el = XDOMUtil.getFirstChildElementNS(groupEl,
      XmlSchema.SCHEMA_NS); el != null; el = XDOMUtil
      .getNextSiblingElementNS(el, XmlSchema.SCHEMA_NS)) {
    if (el.getLocalName().equals("all")) {
      group.particle = handleAll(schema, el, schemaEl);
    } else if (el.getLocalName().equals("sequence")) {
      group.particle = handleSequence(schema, el, schemaEl);
    } else if (el.getLocalName().equals("choice")) {
      group.particle = handleChoice(schema, el, schemaEl);
    } else if (el.getLocalName().equals("annotation")) {
      XmlSchemaAnnotation groupAnnotation = handleAnnotation(el);
      group.setAnnotation(groupAnnotation);
    }
  }
  return group;
}
origin: apache/cxf

protected QName checkPrefix(QName schematypeName) {
  QName name = schematypeName;
  if ((name != null) && (name.getPrefix() == null || name.getPrefix().isEmpty())) {
    if (StringUtils.isEmpty(name.getNamespaceURI())) {
      return name;
    }
    String prefix = def.getPrefix(name.getNamespaceURI());
    if (prefix == null) {
      prefix = xmlSchemaList.getSchemaByTargetNamespace(name.getNamespaceURI())
        .getNamespaceContext().getPrefix(name.getNamespaceURI());
    }
    if (prefix != null) {
      return new QName(name.getNamespaceURI(),
               name.getLocalPart(),
               prefix);
    }
    return null;
  }
  return name;
}
origin: apache/cxf

protected void checkForElement(ServiceInfo serviceInfo, MessagePartInfo mpi) {
  SchemaInfo si = getOrCreateSchema(serviceInfo, mpi.getElementQName().getNamespaceURI(),
                   getQualifyWrapperSchema());
  XmlSchemaElement e = si.getSchema().getElementByName(mpi.getElementQName().getLocalPart());
  if (e != null) {
    mpi.setXmlSchema(e);
    return;
  }
  XmlSchema schema = si.getSchema();
  si.setElement(null); //cached element is now invalid
  XmlSchemaElement el = new XmlSchemaElement(schema, true);
  el.setName(mpi.getElementQName().getLocalPart());
  el.setNillable(true);
  XmlSchemaType tp = (XmlSchemaType)mpi.getXmlSchema();
  if (tp == null) {
    throw new ServiceConstructionException(new Message("INTRACTABLE_PART", LOG,
                              mpi.getName(),
                              mpi.getMessageInfo().getName()));
  }
  el.setSchemaTypeName(tp.getQName());
  mpi.setXmlSchema(el);
}
origin: apache/cxf

/**
 * By convention, an element that is named in its schema's TNS can have a 'name' but
 * no QName. This can get inconvenient for consumers who want to think about qualified names.
 * Unfortunately, XmlSchema elements, unlike types, don't store a reference to their containing
 * schema.
 * @param element
 * @param schema
 */
public static QName getElementQualifiedName(XmlSchemaElement element, XmlSchema schema) {
  if (element.getQName() != null) {
    return element.getQName();
  } else if (element.getName() != null) {
    return new QName(schema.getTargetNamespace(), element.getName());
  } else {
    return null;
  }
}
origin: apache/cxf

public XmlSchemaType getSchemaType(QName name) throws Exception {
  XmlSchemaType type = null;
  for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
    String nspace = name.getNamespaceURI();
    if (nspace == null) {
      nspace = xmlSchema.getTargetNamespace();
    }
    //QName tname = createQName(nspace, name.getLocalPart(), "xsd");
    QName tname = createQName(nspace, name.getLocalPart(), "");
    type = findSchemaType(tname);
    if (type != null) {
      break;
    }
  }
  return type;
}
origin: org.apache.ws.commons.schema/XmlSchema

include.schemaLocation = includeEl.getAttribute("schemaLocation");
if (schema.getSourceURI() != null) {
  include.schema = resolveXmlSchema(schema.logicalTargetNamespace,
      include.schemaLocation, schema.getSourceURI(), validator);
} else {
  include.schema = resolveXmlSchema(schema.logicalTargetNamespace,
origin: org.apache.axis2/axis2-kernel

protected void generateSchemaForSingleElement(QName schemaTypeName,
                       String paraName,
                       boolean isArray) throws Exception {
  XmlSchemaElement elt1 = new XmlSchemaElement(getXmlSchema(schemaTargetNameSpace), false);
  elt1.setName(paraName);
  elt1.setSchemaTypeName(schemaTypeName);
  elt1.setNillable(true);
  QName elementName =
      new QName(schemaTargetNameSpace, paraName, schema_namespace_prefix);
  XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
  xmlSchema.getElements().put(elementName, elt1);
  xmlSchema.getItems().add(elt1);
  typeTable.addComplexSchema(paraName, elementName);
}
origin: apache/cxf

XPathExpression xpe = p.compile(d.getDocumentElement().getAttribute("node"));
for (XmlSchema schema : schemas.getXmlSchemas()) {
  if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(schema.getTargetNamespace())) {
    continue;
  NodeList nodes = (NodeList)xpe.evaluate(src, XPathConstants.NODESET);
  if (nodes.getLength() > 0) {
    String key = schema.getSourceURI();
    binding = convertToTmpInputSource(d.getDocumentElement(), key);
    opts.addBindFile(binding);
origin: apache/cxf

private void createBridgeXsElement(MessagePartInfo part, QName qn, QName typeName) {
  XmlSchemaElement el = null;
  SchemaInfo schemaInfo = serviceInfo.getSchema(qn.getNamespaceURI());
  if (schemaInfo != null) {
    el = schemaInfo.getElementByQName(qn);
    if (el == null) {
      createXsElement(schemaInfo.getSchema(), part, typeName, schemaInfo);
    } else if (!typeName.equals(el.getSchemaTypeName())) {
      throw new Fault(new Message("CANNOT_CREATE_ELEMENT", LOG,
                    qn, typeName, el.getSchemaTypeName()));
    }
    return;
  }
  XmlSchema schema = schemas.newXmlSchemaInCollection(qn.getNamespaceURI());
  if (qualifiedSchemas) {
    schema.setElementFormDefault(XmlSchemaForm.QUALIFIED);
  }
  schemaInfo = new SchemaInfo(qn.getNamespaceURI(), qualifiedSchemas, false);
  schemaInfo.setSchema(schema);
  el = createXsElement(schema, part, typeName, schemaInfo);
  NamespaceMap nsMap = new NamespaceMap();
  nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX, schema.getTargetNamespace());
  nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD);
  schema.setNamespaceContext(nsMap);
  serviceInfo.addSchema(schemaInfo);
}
origin: apache/cxf

/**
 * Since both an Array and a List can have the same type definition, double check that there isn't already
 * a defined type already.
 *
 * @param root
 * @return
 */
private boolean hasDefinedArray(XmlSchema root) {
  return root.getTypeByName(getSchemaType().getLocalPart()) != null;
}
origin: org.apache.axis2/axis2-kernel

private void generateComplexTypeforException() {
  XmlSchemaSequence sequence = new XmlSchemaSequence();
  XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
  QName elementName = new QName(schemaTargetNameSpace, "Exception", schema_namespace_prefix);
  XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema, false);
  complexType.setName("Exception");
  xmlSchema.getItems().add(complexType);
  xmlSchema.getSchemaTypes().put(elementName, complexType);
  typeTable.addComplexSchema(Exception.class.getName(), elementName);
  QName schemaTypeName = new QName(Java2WSDLConstants.URI_2001_SCHEMA_XSD, "string");
  addContentToMethodSchemaType(sequence, schemaTypeName, "Message", false);
  complexType.setParticle(sequence);
}
origin: apache/cxf

private boolean isReferenceSchemaTypeDefined(QName objectReferenceName,
                       XmlSchema refSchema) {
  List<XmlSchemaObject> schemaObjects = refSchema.getItems();
  for (XmlSchemaObject schemaObj : schemaObjects) {
    if (schemaObj instanceof XmlSchemaElement) {
      XmlSchemaElement el = (XmlSchemaElement)schemaObj;
      if (el.getName().equals(objectReferenceName.getLocalPart())) {
        return true;
      }
    }
  }
  return false;
}
origin: apache/cxf

  return element;
if (getSchema() == null) {
  throw new RuntimeException("No XmlSchema in SchemaInfo");
XmlSchema sch = getSchema();
synchronized (sch) {
  XmlSchema schAgain = getSchema();
  if (schAgain.getNamespaceContext() == null) {
    NamespaceMap nsMap = new NamespaceMap();
    nsMap.add("xsd", Constants.URI_2001_SCHEMA_XSD);
    nsMap.add("tns", schAgain.getTargetNamespace());
    schAgain.setNamespaceContext(nsMap);
    serializedSchema = schAgain.getSchemaDocument();
  } catch (XmlSchemaSerializerException e) {
    throw new RuntimeException("Error serializing Xml Schema", e);
if (element.getPrefix() == null
  && !Constants.URI_2001_SCHEMA_XSD.equals(element.getAttributeNS(Constants.XMLNS_ATTRIBUTE_NS_URI,
                                  Constants.XMLNS_ATTRIBUTE))) {
  Attr attr = element.getOwnerDocument()
    .createAttributeNS(Constants.XMLNS_ATTRIBUTE_NS_URI, Constants.XMLNS_ATTRIBUTE);
  attr.setValue(Constants.URI_2001_SCHEMA_XSD);
origin: org.apache.axis2/axis2-kernel

protected void addImport(XmlSchema xmlSchema, QName schemaTypeName) {
  NamespacePrefixList map = xmlSchema.getNamespaceContext();
  if (map == null ||
      ((map instanceof NamespaceMap) && ((NamespaceMap) map).values() == null) ||
      schemaTypeName == null) {
    return;
  }
  if (map instanceof NamespaceMap && !((NamespaceMap) map).values().
      contains(schemaTypeName.getNamespaceURI())) {
    XmlSchemaImport importElement = new XmlSchemaImport(xmlSchema);
    importElement.setNamespace(schemaTypeName.getNamespaceURI());
    if (!xmlSchema.getItems().contains(importElement)) {
      xmlSchema.getItems().add(importElement);
    }
    ((NamespaceMap) xmlSchema.getNamespaceContext()).
        put(generatePrefix(), schemaTypeName.getNamespaceURI());
  }
}
origin: apache/cxf

public static boolean isElementFormQualified(XmlSchema schema, QName type) {
  if (type != null) {
    String uri = type.getNamespaceURI();
    if (uri.equals(schema.getTargetNamespace())) {
      return schema.getElementFormDefault() == XmlSchemaForm.QUALIFIED;
    }
    for (XmlSchemaExternal extSchema : schema.getExternals()) {
      return isElementFormQualified(extSchema.getSchema(), type);
    }
  }
  return false;
}
org.apache.ws.commons.schemaXmlSchema

Javadoc

Contains the definition of a schema. All XML Schema definition language (XSD) elements are children of the schema element. Represents the World Wide Web Consortium (W3C) schema element

Most used methods

  • getTargetNamespace
  • write
    Serialie the schema to a given writer
  • getSourceURI
  • getElements
  • getElementByName
  • getItems
  • getTypeByName
    Protected method that allows safe (non-recursive schema loading). It looks for a type with constrain
  • getNamespaceContext
  • setNamespaceContext
    Sets the schema elements namespace context. This may be used for schema serialization, until a bette
  • getSchemaTypes
  • <init>
    Creates new XmlSchema
  • getExternals
  • <init>,
  • getExternals,
  • getElementFormDefault,
  • setElementFormDefault,
  • getSchemaDocument,
  • getAttributeFormDefault,
  • getIncludes,
  • setTargetNamespace,
  • setAttributeFormDefault,
  • getAttributes

Popular in Java

  • Making http post requests using okhttp
  • setContentView (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • setRequestProperty (URLConnection)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now