當前位置: 首頁>>代碼示例>>Java>>正文


Java TypeInfo.getTypeName方法代碼示例

本文整理匯總了Java中org.w3c.dom.TypeInfo.getTypeName方法的典型用法代碼示例。如果您正苦於以下問題:Java TypeInfo.getTypeName方法的具體用法?Java TypeInfo.getTypeName怎麽用?Java TypeInfo.getTypeName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.w3c.dom.TypeInfo的用法示例。


在下文中一共展示了TypeInfo.getTypeName方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test1

import org.w3c.dom.TypeInfo; //導入方法依賴的package包/類
@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");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:Bug4966138.java

示例2: getAttributeType

import org.w3c.dom.TypeInfo; //導入方法依賴的package包/類
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;
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:24,代碼來源:XMLStreamReaderFromDOM.java

示例3: getAttributeType

import org.w3c.dom.TypeInfo; //導入方法依賴的package包/類
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);
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:14,代碼來源:XIncludeFilter.java

示例4: compatibleRelease

import org.w3c.dom.TypeInfo; //導入方法依賴的package包/類
/**
 * Determine which <CODE>Release</CODE> could be used to represent the indicated
 * <CODE>Document</CODE> at a specific target version. If the target version has
 * multiple views then the message type is used to make the selection.
 * 
 * @param 	document			The source document being converted.
 * @param	source				The <CODE>Release</CODE> object for the source document.
 * @param 	targetVersionNumber	The target version number.
 * @return	The <CODE>Release</CODE> instance for the target schema.
 * @since	TFP 1.7
 */
public static Release compatibleRelease (Document document, Release source, String targetVersionNumber)
{
    Version		sourceVersion = Version.parse (source.getVersion ());
    Version		targetVersion = Version.parse (targetVersionNumber);
    String 		view 		= null;
    String		type		= null;

    // If the target this not 5.0 or later its a direct conversion
    if (targetVersion.getMajor () <= 4)
        return (Releases.FPML.getReleaseForVersion (targetVersionNumber));

    // Otherwise determine the target view based on version and message type
    if (sourceVersion.getMajor () <= 3)
        view = "confirmation";
    else if (sourceVersion.getMajor () == 4) {
        Element root = document.getDocumentElement ();
        TypeInfo info = root.getSchemaTypeInfo ();
        
        if ((info == null) || (info.getTypeName () == null)) {
            NamedNodeMap list = root.getAttributes ();
            for (int index = 0; index < list.getLength (); ++index) {
                Attr attr = (Attr) list.item (index);
                
                if ((attr.getNamespaceURI () != null)
                        && attr.getNamespaceURI ().equals (Schema.INSTANCE_URL)
                        && attr.getLocalName ().equals ("type")) {
                    type = attr.getValue ();
                    break;
                }
            }
        }
        else
            type = info.getTypeName ();

        // Look for messages that are in the reporting view
        if (type.equals ("CancelTradeCashflows")
                || type.equals ("CreditEventNotification")
                || type.equals ("PositionAcknowledged")
                || type.equals ("PositionAsserted")
                || type.equals ("PositionMatchResults")
                || type.equals ("PositionReport")
                || type.equals ("RequestPortfolio")
                || type.equals ("RequestPositionReport")
                || type.equals ("RequestValuationReport")
                || type.equals ("TradeCashflowsAsserted")
                || type.equals ("TradeCashflowsMatchResult")
                || type.equals ("ValuationReport"))
            view = "reporting";
        else
            view = "confirmation";
    }
    else
        view = extractView (((SchemaRelease) source).getNamespaceUri ());
    
    // Find a release that matches the target version and view
    Enumeration<Release> cursor = Releases.FPML.releases ();
    while (cursor.hasMoreElements ()) {
        Release target = cursor.nextElement ();
        if (target.getVersion ().equals (targetVersionNumber)) {
            if (view.equals (extractView (((SchemaRelease) target).getNamespaceUri ())))
                return (target);
        }
    }
    
    // Otherwise no possible release
    return (null);
}
 
開發者ID:handcoded,項目名稱:fpml-toolkit-java,代碼行數:79,代碼來源:Releases.java

示例5: indexNodes

import org.w3c.dom.TypeInfo; //導入方法依賴的package包/類
/**
 * Recursively walks a DOM tree creating an index of the elements by
 * their local name.
 *
 * @param	node 			The next node to be indexed.
 * @since	TFP 1.0
 */
private void indexNodes (Node node)
{
    switch (node.getNodeType ()) {
    case Node.DOCUMENT_NODE:
            indexNodes (((Document) node).getDocumentElement ());
            break;
            
    case Node.ELEMENT_NODE:
        {
            String name = ((Element) node).getLocalName ();
            
            MutableNodeList list = (MutableNodeList) elementsByName.get (name);
        
            if (list == null)
                elementsByName.put (name, list = new MutableNodeList ());
                
            list.add (node);
                            
            TypeInfo typeInfo = ((Element) node).getSchemaTypeInfo ();
            if ((typeInfo != null) && ((name = typeInfo.getTypeName ()) != null)) {
                Vector<TypeInfo> types = typesByName.get (name);
                int		index;
                
                if (types == null)
                    typesByName.put(name, types = new Vector<TypeInfo> ());
                
                for (index = 0; index < types.size (); ++index) {
                    TypeInfo info = (TypeInfo) types.elementAt (index);
                    
                    if (typeInfo.getTypeNamespace ().equals (info.getTypeNamespace ())) break;
                }
                if (index == types.size ()) types.add (typeInfo);
                
                list = (MutableNodeList) elementsByType.get (name);
                
                if (list == null)
                    elementsByType.put (name, list = new MutableNodeList ());
                    
                list.add (node);
            }
            
            Attr id = ((Element) node).getAttributeNode ("id");
            
            if (id != null) elementsById.put (id.getValue (), node);
            
            NamedNodeMap map = ((Element) node).getAttributes ();
            for (int index = 0; index < map.getLength (); ++index) {
                Attr attr = (Attr) map.item (index);
                
                list = (MutableNodeList) attributesByName.get (attr.getName ());
                
                if (list == null)
                    attributesByName.put (attr.getName (), list = new MutableNodeList ());
                
                list.add (attr);					
            }
            
            for (Node child = node.getFirstChild (); child != null;) {
                if (child.getNodeType () == Node.ELEMENT_NODE)
                    indexNodes (child);
                    
                child = child.getNextSibling ();
            }
            break;
        }
    }
}
 
開發者ID:handcoded,項目名稱:fpml-toolkit-java,代碼行數:75,代碼來源:NodeIndex.java


注:本文中的org.w3c.dom.TypeInfo.getTypeName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。