Example usage for org.w3c.dom TypeInfo getTypeName

List of usage examples for org.w3c.dom TypeInfo getTypeName

Introduction

In this page you can find the example usage for org.w3c.dom TypeInfo getTypeName.

Prototype

public String getTypeName();

Source Link

Document

The name of a type declared for the associated element or attribute, or null if unknown.

Usage

From source file:TypeInfoWriter.java

/** Start element. */
public void startElement(String uri, String localName, String qname, Attributes attributes)
        throws SAXException {

    TypeInfo type;
    printIndent();/* ww  w. j ava  2s . c om*/
    fOut.print("startElement(");
    fOut.print("name=");
    printQName(uri, localName);
    fOut.print(',');
    fOut.print("type=");
    if (fTypeInfoProvider != null && (type = fTypeInfoProvider.getElementTypeInfo()) != null) {
        printQName(type.getTypeNamespace(), type.getTypeName());
    } else {
        fOut.print("null");
    }
    fOut.print(',');
    fOut.print("attributes=");
    if (attributes == null) {
        fOut.println("null");
    } else {
        fOut.print('{');
        int length = attributes.getLength();
        for (int i = 0; i < length; i++) {
            if (i > 0) {
                fOut.print(',');
            }
            String attrURI = attributes.getURI(i);
            String attrLocalName = attributes.getLocalName(i);
            fOut.print('{');
            fOut.print("name=");
            printQName(attrURI, attrLocalName);
            fOut.print(',');
            fOut.print("type=");
            if (fTypeInfoProvider != null && (type = fTypeInfoProvider.getAttributeTypeInfo(i)) != null) {
                printQName(type.getTypeNamespace(), type.getTypeName());
            } else {
                fOut.print("null");
            }
            fOut.print(',');
            fOut.print("id=");
            fOut.print(
                    fTypeInfoProvider != null && fTypeInfoProvider.isIdAttribute(i) ? "\"true\"" : "\"false\"");
            fOut.print(',');
            fOut.print("specified=");
            fOut.print(
                    fTypeInfoProvider == null || fTypeInfoProvider.isSpecified(i) ? "\"true\"" : "\"false\"");
            fOut.print('}');
        }
        fOut.print('}');
    }
    fOut.println(')');
    fOut.flush();
    fIndent++;

}

From source file:org.apache.axis2.jaxws.message.util.impl.XMLStreamReaderFromDOM.java

public String getAttributeType(int index) {
    String attrType = null;//from w  w w  . j  a  v  a  2  s. co m
    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;
}