Java 类org.w3c.dom.TypeInfo 实例源码

项目:openjdk-jdk10    文件:Bug4966143.java   
@Test
public void test1() throws Exception {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(true);
    dbf.setAttribute(SCHEMA_LANGUAGE, XMLConstants.W3C_XML_SCHEMA_NS_URI);
    dbf.setAttribute(SCHEMA_SOURCE, Bug4966143.class.getResource("Bug4966143.xsd").toExternalForm());

    Document document = dbf.newDocumentBuilder().parse(Bug4966143.class.getResource("Bug4966143.xml").toExternalForm());

    TypeInfo type = document.getDocumentElement().getSchemaTypeInfo();

    Assert.assertFalse(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_UNION));
    Assert.assertFalse(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_LIST));
    Assert.assertFalse(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_RESTRICTION));
    Assert.assertTrue(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_EXTENSION));
    Assert.assertTrue(type.isDerivedFrom("testNS", "Test", 0));
}
项目:openjdk-jdk10    文件:Bug4966138.java   
@Test
public void test1() throws Exception {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(true);
    dbf.setAttribute(SCHEMA_LANGUAGE, XMLConstants.W3C_XML_SCHEMA_NS_URI);
    dbf.setAttribute(SCHEMA_SOURCE, Bug4966138.class.getResource("test.xsd").toExternalForm());

    Document document = dbf.newDocumentBuilder().parse(Bug4966138.class.getResource("test.xml").toExternalForm());

    TypeInfo type = document.getDocumentElement().getSchemaTypeInfo();

    String typeName = type.getTypeName();
    System.out.println(typeName);
    Assert.assertNotNull(typeName);
    Assert.assertTrue(typeName.length() != 0, "returned typeName shouldn't be empty");

    String typeNs = type.getTypeNamespace();
    System.out.println(typeNs);
    Assert.assertNotNull(typeNs);
    Assert.assertTrue(typeNs.length() != 0, "returned typeNamespace shouldn't be empty");
}
项目:openjdk-jdk10    文件:AuctionController.java   
/**
 * Check usage of TypeInfo interface introduced in DOM L3.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void testGetTypeInfo() throws Exception {
    String xmlFile = XML_DIR + "accountInfo.xml";

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(true);
    dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA_NS_URI);

    DocumentBuilder docBuilder = dbf.newDocumentBuilder();
    docBuilder.setErrorHandler(new MyErrorHandler());

    Document document = docBuilder.parse(xmlFile);
    Element userId = (Element)document.getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "UserID").item(0);
    TypeInfo typeInfo = userId.getSchemaTypeInfo();
    assertTrue(typeInfo.getTypeName().equals("nonNegativeInteger"));
    assertTrue(typeInfo.getTypeNamespace().equals(W3C_XML_SCHEMA_NS_URI));

    Element role = (Element)document.getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "Role").item(0);
    TypeInfo roletypeInfo = role.getSchemaTypeInfo();
    assertTrue(roletypeInfo.getTypeName().equals("BuyOrSell"));
    assertTrue(roletypeInfo.getTypeNamespace().equals(PORTAL_ACCOUNT_NS));
}
项目:openjdk9    文件:Bug4966143.java   
@Test
public void test1() throws Exception {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(true);
    dbf.setAttribute(SCHEMA_LANGUAGE, XMLConstants.W3C_XML_SCHEMA_NS_URI);
    dbf.setAttribute(SCHEMA_SOURCE, Bug4966143.class.getResource("Bug4966143.xsd").toExternalForm());

    Document document = dbf.newDocumentBuilder().parse(Bug4966143.class.getResource("Bug4966143.xml").toExternalForm());

    TypeInfo type = document.getDocumentElement().getSchemaTypeInfo();

    Assert.assertFalse(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_UNION));
    Assert.assertFalse(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_LIST));
    Assert.assertFalse(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_RESTRICTION));
    Assert.assertTrue(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_EXTENSION));
    Assert.assertTrue(type.isDerivedFrom("testNS", "Test", 0));
}
项目:openjdk9    文件:Bug4966138.java   
@Test
public void test1() throws Exception {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(true);
    dbf.setAttribute(SCHEMA_LANGUAGE, XMLConstants.W3C_XML_SCHEMA_NS_URI);
    dbf.setAttribute(SCHEMA_SOURCE, Bug4966138.class.getResource("test.xsd").toExternalForm());

    Document document = dbf.newDocumentBuilder().parse(Bug4966138.class.getResource("test.xml").toExternalForm());

    TypeInfo type = document.getDocumentElement().getSchemaTypeInfo();

    String typeName = type.getTypeName();
    System.out.println(typeName);
    Assert.assertNotNull(typeName);
    Assert.assertTrue(typeName.length() != 0, "returned typeName shouldn't be empty");

    String typeNs = type.getTypeNamespace();
    System.out.println(typeNs);
    Assert.assertNotNull(typeNs);
    Assert.assertTrue(typeNs.length() != 0, "returned typeNamespace shouldn't be empty");
}
项目:openjdk9    文件:AuctionController.java   
/**
 * Check usage of TypeInfo interface introduced in DOM L3.
 *
 * @throws Exception If any errors occur.
 */
@Test(groups = {"readLocalFiles"})
public void testGetTypeInfo() throws Exception {
    String xmlFile = XML_DIR + "accountInfo.xml";

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(true);
    dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA_NS_URI);

    DocumentBuilder docBuilder = dbf.newDocumentBuilder();
    docBuilder.setErrorHandler(new MyErrorHandler());

    Document document = docBuilder.parse(xmlFile);
    Element userId = (Element)document.getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "UserID").item(0);
    TypeInfo typeInfo = userId.getSchemaTypeInfo();
    assertTrue(typeInfo.getTypeName().equals("nonNegativeInteger"));
    assertTrue(typeInfo.getTypeNamespace().equals(W3C_XML_SCHEMA_NS_URI));

    Element role = (Element)document.getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "Role").item(0);
    TypeInfo roletypeInfo = role.getSchemaTypeInfo();
    assertTrue(roletypeInfo.getTypeName().equals("BuyOrSell"));
    assertTrue(roletypeInfo.getTypeNamespace().equals(PORTAL_ACCOUNT_NS));
}
项目:javify    文件:XMLSchemaTypeInfo.java   
protected boolean simpleTypeIsDerivedFrom(SimpleType simpleType,
                                          String typeNamespace,
                                          String typeName,
                                          int derivationMethod)
{
  switch (derivationMethod)
    {
    case TypeInfo.DERIVATION_RESTRICTION:
      SimpleType baseType = simpleType.baseType;
      while (baseType != null)
        {
          if (baseType.name.getNamespaceURI().equals(typeNamespace) &&
              baseType.name.getLocalPart().equals(typeName))
            {
              return true;
            }
          baseType = baseType.baseType;
        }
      break;
      // TODO other methods
    }
  return false;
}
项目:jvm-stm    文件:XMLSchemaTypeInfo.java   
protected boolean simpleTypeIsDerivedFrom(SimpleType simpleType,
                                          String typeNamespace,
                                          String typeName,
                                          int derivationMethod)
{
  switch (derivationMethod)
    {
    case TypeInfo.DERIVATION_RESTRICTION:
      SimpleType baseType = simpleType.baseType;
      while (baseType != null)
        {
          if (baseType.name.getNamespaceURI().equals(typeNamespace) &&
              baseType.name.getLocalPart().equals(typeName))
            {
              return true;
            }
          baseType = baseType.baseType;
        }
      break;
      // TODO other methods
    }
  return false;
}
项目:JamVM-PH    文件:XMLSchemaTypeInfo.java   
protected boolean simpleTypeIsDerivedFrom(SimpleType simpleType,
                                          String typeNamespace,
                                          String typeName,
                                          int derivationMethod)
{
  switch (derivationMethod)
    {
    case TypeInfo.DERIVATION_RESTRICTION:
      SimpleType baseType = simpleType.baseType;
      while (baseType != null)
        {
          if (baseType.name.getNamespaceURI().equals(typeNamespace) &&
              baseType.name.getLocalPart().equals(typeName))
            {
              return true;
            }
          baseType = baseType.baseType;
        }
      break;
      // TODO other methods
    }
  return false;
}
项目:wso2-axis2    文件:XMLStreamReaderFromDOM.java   
public String getAttributeType(int index) {
    String attrType = null;    
    Attr attr = (Attr)getAttributes().get(index);
    TypeInfo typeInfo = attr.getSchemaTypeInfo();
 if (typeInfo != null) {
    attrType = typeInfo.getTypeName();
    }

    if (attrType == null) {
        try {
            attrType = (String) attr.getUserData(SAAJConverter.OM_ATTRIBUTE_KEY);
            if (log.isDebugEnabled()) {
                log.debug("Retrieving attrType from UserData: " + attrType);
            }
        } catch (Exception e) {
            if (log.isDebugEnabled()) {
                log.debug("An error occured while getting attrType: " + e.getMessage());
            }
        }
    }

    return attrType;
}
项目:classpath    文件:XMLSchemaTypeInfo.java   
protected boolean simpleTypeIsDerivedFrom(SimpleType simpleType,
                                          String typeNamespace,
                                          String typeName,
                                          int derivationMethod)
{
  switch (derivationMethod)
    {
    case TypeInfo.DERIVATION_RESTRICTION:
      SimpleType baseType = simpleType.baseType;
      while (baseType != null)
        {
          if (baseType.name.getNamespaceURI().equals(typeNamespace) &&
              baseType.name.getLocalPart().equals(typeName))
            {
              return true;
            }
          baseType = baseType.baseType;
        }
      break;
      // TODO other methods
    }
  return false;
}
项目:hybris-integration-intellij-idea-plugin    文件:XSDModelLoader.java   
public String toJavaTypeName(XSObject xs, Map<String, NamespaceDesc> nsdMap) {
    String name = xs.getName();
    if (name == null) {
        if (xs instanceof TypeInfo) {
            name = ((TypeInfo) xs).getTypeName();
            if (name != null && name.startsWith("#")) {
                name = name.substring(1);
            }
        }
    }
    return model.toJavaTypeName(name, xs.getNamespace());
}
项目:OpenJSharp    文件:ElementImpl.java   
/**
     * Method getSchemaTypeInfo.
     * @return TypeInfo
     */
public TypeInfo getSchemaTypeInfo(){
    if(needsSyncData()) {
        synchronizeData();
    }
    return this;
}
项目:OpenJSharp    文件:ValidatorHandlerImpl.java   
private TypeInfo getAttributeType( int index ) {
    checkState(false);
    if( index<0 || fAttributes.getLength()<=index )
        throw new IndexOutOfBoundsException(Integer.toString(index));
    Augmentations augs = fAttributes.getAugmentations(index);
    if (augs == null) return null;
    AttributePSVI psvi = (AttributePSVI)augs.getItem(Constants.ATTRIBUTE_PSVI);
    return getTypeInfoFromPSVI(psvi);
}
项目:openjdk-jdk10    文件:ElementImpl.java   
/**
 * Method getSchemaTypeInfo.
 *
 * @return TypeInfo
 */
public TypeInfo getSchemaTypeInfo() {
    if (needsSyncData()) {
        synchronizeData();
    }
    return this;
}
项目:openjdk-jdk10    文件:ValidatorHandlerImpl.java   
private TypeInfo getAttributeType( int index ) {
    checkState(false);
    if( index<0 || fAttributes.getLength()<=index )
        throw new IndexOutOfBoundsException(Integer.toString(index));
    Augmentations augs = fAttributes.getAugmentations(index);
    if (augs == null) return null;
    AttributePSVI psvi = (AttributePSVI)augs.getItem(Constants.ATTRIBUTE_PSVI);
    return getTypeInfoFromPSVI(psvi);
}
项目:openjdk-jdk10    文件:Bug4966142.java   
@Test
public void test1() throws Exception {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(true);
    dbf.setAttribute(SCHEMA_LANGUAGE, XMLConstants.W3C_XML_SCHEMA_NS_URI);
    dbf.setAttribute(SCHEMA_SOURCE, Bug4966142.class.getResource("Bug4966142.xsd").toExternalForm());

    Document document = dbf.newDocumentBuilder().parse(Bug4966142.class.getResource("Bug4966142.xml").toExternalForm());

    TypeInfo type = document.getDocumentElement().getSchemaTypeInfo();

    Assert.assertFalse(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_UNION));
}
项目:openjdk-jdk10    文件:TypeInfoTest.java   
@Test
public void test() throws Exception {
    TypeInfo typeInfo = getTypeOfRoot(SCHEMA_INSTANCE, "<?xml version='1.0'?>\n" + "<test1 xmlns=\"testNS\"><code/></test1>\n");

    assertEquals(typeInfo.getTypeName(), "Test");
    assertEquals(typeInfo.getTypeNamespace(), "testNS");

}
项目:openjdk9    文件:ElementImpl.java   
/**
 * Method getSchemaTypeInfo.
 *
 * @return TypeInfo
 */
public TypeInfo getSchemaTypeInfo() {
    if (needsSyncData()) {
        synchronizeData();
    }
    return this;
}
项目:openjdk9    文件:ValidatorHandlerImpl.java   
private TypeInfo getAttributeType( int index ) {
    checkState(false);
    if( index<0 || fAttributes.getLength()<=index )
        throw new IndexOutOfBoundsException(Integer.toString(index));
    Augmentations augs = fAttributes.getAugmentations(index);
    if (augs == null) return null;
    AttributePSVI psvi = (AttributePSVI)augs.getItem(Constants.ATTRIBUTE_PSVI);
    return getTypeInfoFromPSVI(psvi);
}
项目:openjdk9    文件:Bug4966142.java   
@Test
public void test1() throws Exception {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(true);
    dbf.setAttribute(SCHEMA_LANGUAGE, XMLConstants.W3C_XML_SCHEMA_NS_URI);
    dbf.setAttribute(SCHEMA_SOURCE, Bug4966142.class.getResource("Bug4966142.xsd").toExternalForm());

    Document document = dbf.newDocumentBuilder().parse(Bug4966142.class.getResource("Bug4966142.xml").toExternalForm());

    TypeInfo type = document.getDocumentElement().getSchemaTypeInfo();

    Assert.assertFalse(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_UNION));
}
项目:openjdk9    文件:TypeInfoTest.java   
@Test
public void test() throws Exception {
    TypeInfo typeInfo = getTypeOfRoot(SCHEMA_INSTANCE, "<?xml version='1.0'?>\n" + "<test1 xmlns=\"testNS\"><code/></test1>\n");

    assertEquals(typeInfo.getTypeName(), "Test");
    assertEquals(typeInfo.getTypeNamespace(), "testNS");

}
项目:Push2Display    文件:AbstractElement.java   
/**
 * <b>DOM</b>: Implements {@link org.w3c.dom.Element#getSchemaTypeInfo()}.
 */
public TypeInfo getSchemaTypeInfo() {
    if (typeInfo == null) {
        typeInfo = new ElementTypeInfo();
    }
    return typeInfo;
}
项目:Push2Display    文件:AbstractAttr.java   
/**
 * <b>DOM</b>: Implements {@link org.w3c.dom.Attr#getSchemaTypeInfo()}.
 */
public TypeInfo getSchemaTypeInfo() {
    if (typeInfo == null) {
        typeInfo = new AttrTypeInfo();
    }
    return typeInfo;
}
项目:lookaside_java-1.8.0-openjdk    文件:ElementImpl.java   
/**
     * Method getSchemaTypeInfo.
     * @return TypeInfo
     */
public TypeInfo getSchemaTypeInfo(){
    if(needsSyncData()) {
        synchronizeData();
    }
    return this;
}
项目:lookaside_java-1.8.0-openjdk    文件:ValidatorHandlerImpl.java   
private TypeInfo getAttributeType( int index ) {
    checkState(false);
    if( index<0 || fAttributes.getLength()<=index )
        throw new IndexOutOfBoundsException(Integer.toString(index));
    Augmentations augs = fAttributes.getAugmentations(index);
    if (augs == null) return null;
    AttributePSVI psvi = (AttributePSVI)augs.getItem(Constants.ATTRIBUTE_PSVI);
    return getTypeInfoFromPSVI(psvi);
}
项目:javify    文件:XIncludeFilter.java   
public String getAttributeType(int index)
{
  if (current != null)
    {
      NamedNodeMap attrs = current.getAttributes();
      if (attrs == null)
       return null;
      Attr attr = (Attr) attrs.item(index);
      TypeInfo ti = attr.getSchemaTypeInfo();
      return (ti == null) ? "CDATA" : ti.getTypeName();
    }
  return super.getAttributeType(index);
}
项目:javify    文件:DomAttr.java   
public TypeInfo getSchemaTypeInfo()
{
  if (parent != null)
    {
      // DTD implementation
      DomDoctype doctype = (DomDoctype) parent.owner.getDoctype();
      if (doctype != null)
        {
          return doctype.getAttributeTypeInfo(parent.getNodeName(),
                                              getNodeName());
        }
      // TODO XML Schema implementation
    }
  return null;
}
项目:javify    文件:DomElement.java   
public TypeInfo getSchemaTypeInfo()
{
  // DTD implementation
  DomDoctype doctype = (DomDoctype) owner.getDoctype();
  if (doctype != null)
    {
      return doctype.getElementTypeInfo(getNodeName());
    }
  // TODO XML Schema implementation
  return null;
}
项目:intellij-ce-playground    文件:XSDModelLoader.java   
public String toJavaTypeName(XSObject xs, Map<String, NamespaceDesc> nsdMap) {
  String name = xs.getName();
  if (name == null) {
    if (xs instanceof TypeInfo) {
      name = ((TypeInfo) xs).getTypeName();
      if (name != null && name.startsWith("#")) {
        name = name.substring(1);
      }
    }
  }
  return model.toJavaTypeName(name, xs.getNamespace());
}
项目:jvm-stm    文件:XIncludeFilter.java   
public String getAttributeType(int index)
{
  if (current != null)
    {
      NamedNodeMap attrs = current.getAttributes();
      if (attrs == null)
       return null;
      Attr attr = (Attr) attrs.item(index);
      TypeInfo ti = attr.getSchemaTypeInfo();
      return (ti == null) ? "CDATA" : ti.getTypeName();
    }
  return super.getAttributeType(index);
}
项目:jvm-stm    文件:DomAttr.java   
public TypeInfo getSchemaTypeInfo()
{
  if (parent != null)
    {
      // DTD implementation
      DomDoctype doctype = (DomDoctype) parent.owner.getDoctype();
      if (doctype != null)
        {
          return doctype.getAttributeTypeInfo(parent.getNodeName(),
                                              getNodeName());
        }
      // TODO XML Schema implementation
    }
  return null;
}
项目:jvm-stm    文件:DomElement.java   
public TypeInfo getSchemaTypeInfo()
{
  // DTD implementation
  DomDoctype doctype = (DomDoctype) owner.getDoctype();
  if (doctype != null)
    {
      return doctype.getElementTypeInfo(getNodeName());
    }
  // TODO XML Schema implementation
  return null;
}
项目:Push2Display    文件:AbstractElement.java   
/**
 * <b>DOM</b>: Implements {@link org.w3c.dom.Element#getSchemaTypeInfo()}.
 */
public TypeInfo getSchemaTypeInfo() {
    if (typeInfo == null) {
        typeInfo = new ElementTypeInfo();
    }
    return typeInfo;
}
项目:Push2Display    文件:AbstractAttr.java   
/**
 * <b>DOM</b>: Implements {@link org.w3c.dom.Attr#getSchemaTypeInfo()}.
 */
public TypeInfo getSchemaTypeInfo() {
    if (typeInfo == null) {
        typeInfo = new AttrTypeInfo();
    }
    return typeInfo;
}
项目:Lucee4    文件:XMLElementStruct.java   
public TypeInfo getSchemaTypeInfo() {
    // dynamic load to support jre 1.4 and 1.5
    try {
        Method m = element.getClass().getMethod("getSchemaTypeInfo", new Class[]{});
        return (TypeInfo) m.invoke(element, ArrayUtil.OBJECT_EMPTY);
    } 
    catch (Exception e) {
        throw new PageRuntimeException(Caster.toPageException(e));
    }
}
项目:infobip-open-jdk-8    文件:ElementImpl.java   
/**
     * Method getSchemaTypeInfo.
     * @return TypeInfo
     */
public TypeInfo getSchemaTypeInfo(){
    if(needsSyncData()) {
        synchronizeData();
    }
    return this;
}
项目:infobip-open-jdk-8    文件:ValidatorHandlerImpl.java   
private TypeInfo getAttributeType( int index ) {
    checkState(false);
    if( index<0 || fAttributes.getLength()<=index )
        throw new IndexOutOfBoundsException(Integer.toString(index));
    Augmentations augs = fAttributes.getAugmentations(index);
    if (augs == null) return null;
    AttributePSVI psvi = (AttributePSVI)augs.getItem(Constants.ATTRIBUTE_PSVI);
    return getTypeInfoFromPSVI(psvi);
}
项目:Lucee    文件:XMLElementStruct.java   
public TypeInfo getSchemaTypeInfo() {
    // dynamic load to support jre 1.4 and 1.5
    try {
        Method m = element.getClass().getMethod("getSchemaTypeInfo", new Class[]{});
        return (TypeInfo) m.invoke(element, ArrayUtil.OBJECT_EMPTY);
    } 
    catch (Exception e) {
        throw new PageRuntimeException(Caster.toPageException(e));
    }
}
项目:feathers-sdk    文件:AbstractElement.java   
/**
 * <b>DOM</b>: Implements {@link org.w3c.dom.Element#getSchemaTypeInfo()}.
 */
public TypeInfo getSchemaTypeInfo() {
    if (typeInfo == null) {
        typeInfo = new ElementTypeInfo();
    }
    return typeInfo;
}