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


Java Entity.getSystemId方法代码示例

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


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

示例1: enter

import org.w3c.dom.Entity; //导入方法依赖的package包/类
public boolean enter(Entity entity) {
    String name = entity.getNodeName();
    String pubId = entity.getPublicId();
    String sysId = entity.getSystemId();
    String notation = entity.getNotationName();
    buffer.append("<!ENTITY ");
    buffer.append(name);
    if (pubId != null) {
        buffer.append(" PUBLIC \"");
        buffer.append(pubId);
        buffer.append("\"");
    }
    if (sysId != null) {
        buffer.append(" SYSTEM \"");
        buffer.append(sysId);
        buffer.append("\"");
    }
    if (notation != null) {
        buffer.append(" NDATA ");
        buffer.append(notation);
    }
    buffer.append(">");
    return true;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:25,代码来源:SaveContextVisitor.java

示例2: getUnparsedEntityURI

import org.w3c.dom.Entity; //导入方法依赖的package包/类
/**
 * The getUnparsedEntityURI function returns the URI of the unparsed
 * entity with the specified name in the same document as the context
 * node (see [3.3 Unparsed Entities]). It returns the empty string if
 * there is no such entity.
 */
public String getUnparsedEntityURI(String name)
{
    // Special handling for DOM input
    if (_document != null) {
        String uri = "";
        DocumentType doctype = _document.getDoctype();
        if (doctype != null) {
            NamedNodeMap entities = doctype.getEntities();

            if (entities == null) {
                return uri;
            }

            Entity entity = (Entity) entities.getNamedItem(name);

            if (entity == null) {
                return uri;
            }

            String notationName = entity.getNotationName();
            if (notationName != null) {
                uri = entity.getSystemId();
                if (uri == null) {
                    uri = entity.getPublicId();
                }
            }
        }
        return uri;
    }
    else {
        return super.getUnparsedEntityURI(name);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:SAXImpl.java

示例3: getUnparsedEntities

import org.w3c.dom.Entity; //导入方法依赖的package包/类
private List<UnparsedEntity> getUnparsedEntities(NamedNodeMap entities) {
    List<UnparsedEntity> result = new ArrayList<UnparsedEntity>();
    for (int i = 0; i < entities.getLength(); i++) {
        Entity n = (Entity) entities.item(i);
        String systemid = n.getSystemId();
        String notationname = n.getNotationName();
        if (systemid != null && notationname != null) {
            result.add(new UnparsedEntity(n.getNodeName(), systemid, n.getPublicId(), notationname));
        }
    }
    return result;
}
 
开发者ID:rpablos,项目名称:FastInfoset,代码行数:13,代码来源:DOM_FI_Encoder.java

示例4: getUnparsedEntityURI

import org.w3c.dom.Entity; //导入方法依赖的package包/类
/**
 * The getUnparsedEntityURI function returns the URI of the unparsed
 * entity with the specified name in the same document as the context
 * node (see [3.3 Unparsed Entities]). It returns the empty string if
 * there is no such entity.
 * <p>
 * XML processors may choose to use the System Identifier (if one
 * is provided) to resolve the entity, rather than the URI in the
 * Public Identifier. The details are dependent on the processor, and
 * we would have to support some form of plug-in resolver to handle
 * this properly. Currently, we simply return the System Identifier if
 * present, and hope that it a usable URI or that our caller can
 * map it to one.
 * TODO: Resolve Public Identifiers... or consider changing function name.
 * <p>
 * If we find a relative URI
 * reference, XML expects it to be resolved in terms of the base URI
 * of the document. The DOM doesn't do that for us, and it isn't
 * entirely clear whether that should be done here; currently that's
 * pushed up to a higher levelof our application. (Note that DOM Level
 * 1 didn't store the document's base URI.)
 * TODO: Consider resolving Relative URIs.
 * <p>
 * (The DOM's statement that "An XML processor may choose to
 * completely expand entities before the structure model is passed
 * to the DOM" refers only to parsed entities, not unparsed, and hence
 * doesn't affect this function.)
 *
 * @param name A string containing the Entity Name of the unparsed
 * entity.
 * @param doc Document node for the document to be searched.
 *
 * @return String containing the URI of the Unparsed Entity, or an
 * empty string if no such entity exists.
 */
public String getUnparsedEntityURI(String name, Document doc)
{

  String url = "";
  DocumentType doctype = doc.getDoctype();

  if (null != doctype)
  {
    NamedNodeMap entities = doctype.getEntities();
    if(null == entities)
      return url;
    Entity entity = (Entity) entities.getNamedItem(name);
    if(null == entity)
      return url;

    String notationName = entity.getNotationName();

    if (null != notationName)  // then it's unparsed
    {
      // The draft says: "The XSLT processor may use the public
      // identifier to generate a URI for the entity instead of the URI
      // specified in the system identifier. If the XSLT processor does
      // not use the public identifier to generate the URI, it must use
      // the system identifier; if the system identifier is a relative
      // URI, it must be resolved into an absolute URI using the URI of
      // the resource containing the entity declaration as the base
      // URI [RFC2396]."
      // So I'm falling a bit short here.
      url = entity.getSystemId();

      if (null == url)
      {
        url = entity.getPublicId();
      }
      else
      {
        // This should be resolved to an absolute URL, but that's hard
        // to do from here.
      }
    }
  }

  return url;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:80,代码来源:DOMHelper.java

示例5: getUnparsedEntityURI

import org.w3c.dom.Entity; //导入方法依赖的package包/类
/**
 * The getUnparsedEntityURI function returns the URI of the unparsed
 * entity with the specified name in the same document as the context
 * node (see [3.3 Unparsed Entities]). It returns the empty string if
 * there is no such entity.
 * <p>
 * XML processors may choose to use the System Identifier (if one
 * is provided) to resolve the entity, rather than the URI in the
 * Public Identifier. The details are dependent on the processor, and
 * we would have to support some form of plug-in resolver to handle
 * this properly. Currently, we simply return the System Identifier if
 * present, and hope that it a usable URI or that our caller can
 * map it to one.
 * TODO: Resolve Public Identifiers... or consider changing function name.
 * <p>
 * If we find a relative URI 
 * reference, XML expects it to be resolved in terms of the base URI 
 * of the document. The DOM doesn't do that for us, and it isn't 
 * entirely clear whether that should be done here; currently that's
 * pushed up to a higher levelof our application. (Note that DOM Level 
 * 1 didn't store the document's base URI.)
 * TODO: Consider resolving Relative URIs.
 * <p>
 * (The DOM's statement that "An XML processor may choose to
 * completely expand entities before the structure model is passed
 * to the DOM" refers only to parsed entities, not unparsed, and hence
 * doesn't affect this function.)
 *
 * @param name A string containing the Entity Name of the unparsed
 * entity.
 * @param doc Document node for the document to be searched.
 *
 * @return String containing the URI of the Unparsed Entity, or an
 * empty string if no such entity exists.
 */
public String getUnparsedEntityURI(String name, Document doc)
{

  String url = "";
  DocumentType doctype = doc.getDoctype();

  if (null != doctype)
  {
    NamedNodeMap entities = doctype.getEntities();
    if(null == entities)
      return url;
    Entity entity = (Entity) entities.getNamedItem(name);
    if(null == entity)
      return url;
    
    String notationName = entity.getNotationName();

    if (null != notationName)  // then it's unparsed
    {
      // The draft says: "The XSLT processor may use the public 
      // identifier to generate a URI for the entity instead of the URI 
      // specified in the system identifier. If the XSLT processor does 
      // not use the public identifier to generate the URI, it must use 
      // the system identifier; if the system identifier is a relative 
      // URI, it must be resolved into an absolute URI using the URI of 
      // the resource containing the entity declaration as the base 
      // URI [RFC2396]."
      // So I'm falling a bit short here.
      url = entity.getSystemId();

      if (null == url)
      {
        url = entity.getPublicId();
      }
      else
      {
        // This should be resolved to an absolute URL, but that's hard 
        // to do from here.
      }        
    }
  }

  return url;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:80,代码来源:DOMHelper.java


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