当前位置: 首页>>代码示例>>Java>>正文


Java Attr.getSpecified方法代码示例

本文整理汇总了Java中org.w3c.dom.Attr.getSpecified方法的典型用法代码示例。如果您正苦于以下问题:Java Attr.getSpecified方法的具体用法?Java Attr.getSpecified怎么用?Java Attr.getSpecified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.Attr的用法示例。


在下文中一共展示了Attr.getSpecified方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: normalizeAttributeValue

import org.w3c.dom.Attr; //导入方法依赖的package包/类
final String normalizeAttributeValue(String value, Attr attr) {
    if (!attr.getSpecified()){
        // specified attributes should already have a normalized form
        // since those were added by validator
        return value;
    }
    int end = value.length();
    // ensure capacity
    if (fNormalizedValue.ch.length < end) {
        fNormalizedValue.ch = new char[end];
    }
    fNormalizedValue.length = 0;
    boolean normalized = false;
    for (int i = 0; i < end; i++) {
        char c = value.charAt(i);
        if (c==0x0009 || c==0x000A) {
           fNormalizedValue.ch[fNormalizedValue.length++] = ' ';
           normalized = true;
        }
        else if(c==0x000D){
           normalized = true;
           fNormalizedValue.ch[fNormalizedValue.length++] = ' ';
           int next = i+1;
           if (next < end && value.charAt(next)==0x000A) i=next; // skip following xA
        }
        else {
            fNormalizedValue.ch[fNormalizedValue.length++] = c;
        }
    }
    if (normalized){
       value = fNormalizedValue.toString();
       attr.setValue(value);
    }
    return value;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:DOMNormalizer.java

示例2: isAttributeSpecified

import org.w3c.dom.Attr; //导入方法依赖的package包/类
/**
 *     5. [specified] A flag indicating whether this attribute was actually
 *        specified in the start-tag of its element, or was defaulted from the
 *        DTD.
 *
 * @param attributeHandle the attribute handle
 * @return <code>true</code> if the attribute was specified;
 *         <code>false</code> if it was defaulted.
 */
public boolean isAttributeSpecified(int attributeHandle)
{
  int type = getNodeType(attributeHandle);

  if (DTM.ATTRIBUTE_NODE == type)
  {
    Attr attr = (Attr)getNode(attributeHandle);
    return attr.getSpecified();
  }
  return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:DOM2DTM.java

示例3: startElement

import org.w3c.dom.Attr; //导入方法依赖的package包/类
/**
* The start of an element.
*
* @param element    The name of the element.
* @param attributes The element attributes.
* @param augs       Additional information that may include infoset augmentations
*
* @exception XNIException
*                   Thrown by handler to signal an error.
*/
   public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
           throws XNIException {
           Element currentElement = (Element) fCurrentNode;
           int attrCount = attributes.getLength();
   if (DEBUG_EVENTS) {
       System.out.println("==>startElement: " +element+
       " attrs.length="+attrCount);
   }

           for (int i = 0; i < attrCount; i++) {
                   attributes.getName(i, fAttrQName);
                   Attr attr = null;

                   attr = currentElement.getAttributeNodeNS(fAttrQName.uri, fAttrQName.localpart);
       AttributePSVI attrPSVI =
                           (AttributePSVI) attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);

                   if (attrPSVI != null) {
           //REVISIT: instead we should be using augmentations:
           // to set/retrieve Id attributes
           XSTypeDefinition decl = attrPSVI.getMemberTypeDefinition();
           boolean id = false;
           if (decl != null){
               id = ((XSSimpleType)decl).isIDType();
           } else{
               decl = attrPSVI.getTypeDefinition();
               if (decl !=null){
                  id = ((XSSimpleType)decl).isIDType();
               }
           }
           if (id){
               ((ElementImpl)currentElement).setIdAttributeNode(attr, true);
           }

                           if (fPSVI) {
                                   ((PSVIAttrNSImpl) attr).setPSVI(attrPSVI);
                           }
                           if ((fConfiguration.features & DOMConfigurationImpl.DTNORMALIZATION) != 0) {
                                   // datatype-normalization
                                   // NOTE: The specified value MUST be set after we set
                                   //       the node value because that turns the "specified"
                                   //       flag to "true" which may overwrite a "false"
                                   //       value from the attribute list.
                                   boolean specified = attr.getSpecified();
                                   attr.setValue(attrPSVI.getSchemaNormalizedValue());
                                   if (!specified) {
                                           ((AttrImpl) attr).setSpecified(specified);
                                   }
                           }
                   }
           }
   }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:63,代码来源:DOMNormalizer.java

示例4: startElement

import org.w3c.dom.Attr; //导入方法依赖的package包/类
/**
* The start of an element.
*
* @param element    The name of the element.
* @param attributes The element attributes.
* @param augs       Additional information that may include infoset augmentations
*
* @exception XNIException
*                   Thrown by handler to signal an error.
*/
   public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
           throws XNIException {
           Element currentElement = (Element) fCurrentNode;
           int attrCount = attributes.getLength();
   if (DEBUG_EVENTS) {
       System.out.println("==>startElement: " +element+
       " attrs.length="+attrCount);
   }

           for (int i = 0; i < attrCount; i++) {
                   attributes.getName(i, fAttrQName);
                   Attr attr = null;

                   attr = currentElement.getAttributeNodeNS(fAttrQName.uri, fAttrQName.localpart);
       AttributePSVI attrPSVI =
                           (AttributePSVI) attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);

                   if (attrPSVI != null) {
           //REVISIT: instead we should be using augmentations:
           // to set/retrieve Id attributes
           XSTypeDefinition decl = attrPSVI.getMemberTypeDefinition();
           boolean id = false;
           if (decl != null){
               id = ((XSSimpleType)decl).isIDType();
           } else{
               decl = attrPSVI.getTypeDefinition();
               if (decl !=null){
                  id = ((XSSimpleType)decl).isIDType();
               }
           }
           if (id){
               ((ElementImpl)currentElement).setIdAttributeNode(attr, true);
           }

                           if (fPSVI) {
                                   ((PSVIAttrNSImpl) attr).setPSVI(attrPSVI);
                           }
                           if ((fConfiguration.features & DOMConfigurationImpl.DTNORMALIZATION) != 0) {
                                   // datatype-normalization
                                   // NOTE: The specified value MUST be set after we set
                                   //       the node value because that turns the "specified"
                                   //       flag to "true" which may overwrite a "false"
                                   //       value from the attribute list.
                                   boolean specified = attr.getSpecified();
                                   attr.setValue(attrPSVI.getSchemaValue().getNormalizedValue());
                                   if (!specified) {
                                           ((AttrImpl) attr).setSpecified(specified);
                                   }
                           }
                   }
           }
   }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:63,代码来源:DOMNormalizer.java


注:本文中的org.w3c.dom.Attr.getSpecified方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。