org.jdom.DocType类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(191)

本文整理了Java中org.jdom.DocType类的一些代码示例,展示了DocType类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DocType类的具体详情如下:
包路径:org.jdom.DocType
类名称:DocType

DocType介绍

[英]An XML DOCTYPE declaration. Method allow the user to get and set the root element name, public id, and system id.
[中]XML DOCTYPE声明。方法允许用户获取和设置根元素名称、公共id和系统id。

代码示例

代码示例来源:origin: org.freemarker/freemarker

DocType doctype = (DocType) node;
if ("publicId".equals(localName)) {
  result.add(new Attribute("publicId", doctype.getPublicID()));
} else if ("systemId".equals(localName)) {
  result.add(new Attribute("systemId", doctype.getSystemID()));
} else if ("elementName".equals(localName)) {
  result.add(new Attribute("elementName", doctype.getElementName()));

代码示例来源:origin: org.sonatype.maven.archetype/archetype-common

String publicID=docType.getPublicID();
String systemID=docType.getSystemID();
String internalSubset=docType.getInternalSubset();
boolean hasPublic=false;
out.write(docType.getElementName());
if (publicID != null) {
  out.write(" PUBLIC \"");
  out.write(" [");
  out.write(currentFormat.lineSeparator);
  out.write(docType.getInternalSubset());
  out.write("]");

代码示例来源:origin: org.jdom/jdom-legacy

public DocType docType(String elementName, String publicID, String systemID) {
  DocType d = new DocType();
  d.elementName = elementName;
  d.publicID = publicID;
  d.systemID = systemID;
  return d;
}

代码示例来源:origin: org.freemarker/freemarker

public List operate(Object node) {
      if (node instanceof Element)
        return Collections.singletonList(((Element) node).getName());
      else if (node instanceof Attribute)
        return Collections.singletonList(((Attribute) node).getName());
      else if (node instanceof EntityRef)
        return Collections.singletonList(((EntityRef) node).getName());
      else if (node instanceof ProcessingInstruction)
        return Collections.singletonList(((ProcessingInstruction) node).getTarget());
      else if (node instanceof DocType)
        return Collections.singletonList(((DocType) node).getPublicID());
      else
        return null;
      // With 2.1 semantics it  makes more sense to just return a null and let the core 
      // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR)
//                throw new TemplateModelException("_name can not be applied on " + node.getClass());
    }
  }

代码示例来源:origin: org.jibx/jibx-extras

public void writeDocType(String name, String sys, String pub, String subset)
    throws IOException {
  DocType docType;
  if(null != pub) {
    docType = new DocType(name, pub, sys);
  } else if(null != sys) {
    docType = new DocType(name, sys);
  } else {
    docType = new DocType(name);
  }
  if(null != subset) {
    docType.setInternalSubset(subset);
  }
  this.document.setDocType(docType);
}

代码示例来源:origin: org.jdom/jdom-legacy

/**
 * <p>
 * This method tells you the line of the XML file being parsed.
 * For an in-memory document, it's meaningless. The location
 * is only valid for the current parsing lifecycle, but
 * the document has already been parsed. Therefore, it returns
 * -1 for both line and column numbers.
 * </p>
 *
 * @param document JDOM <code>Document</code>.
 */
private void documentLocator(Document document) {
  locator = new JDOMLocator();
  String publicID = null;
  String systemID = null;
  if (document != null) {
    DocType docType = document.getDocType();
    if (docType != null) {
      publicID = docType.getPublicID();
      systemID = docType.getSystemID();
    }
  }
  locator.setPublicId(publicID);
  locator.setSystemId(systemID);
  locator.setLineNumber(-1);
  locator.setColumnNumber(-1);
  contentHandler.setDocumentLocator(locator);
}

代码示例来源:origin: org.freemarker/freemarker

@Override
String getLocalName(Object node) {
  if (node instanceof Element) {
    return ((Element) node).getName();
  }
  if (node instanceof Attribute) {
    return ((Attribute) node).getName();
  }
  if (node instanceof EntityRef) {
    return ((EntityRef) node).getName();
  }
  if (node instanceof ProcessingInstruction) {
    return ((ProcessingInstruction) node).getTarget();
  }
  if (node instanceof DocType) {
    return ((DocType) node).getElementName();
  }
  return null;
}

代码示例来源:origin: org.jdom/jdom-legacy

docType.setPublicID(publicID);
docType.setSystemID(systemID);
docType.setInternalSubset(internalDTD);

代码示例来源:origin: org.jdom/jdom-legacy

/**
 * This signifies that the reading of the DTD is complete.
 *
 * @throws SAXException
 */
public void endDTD() throws SAXException {
  document.getDocType().setInternalSubset(internalSubset.toString());
  inDTD = false;
  inInternalSubset = false;
}

代码示例来源:origin: org.jdom/jdom-legacy

throws IOException {
String publicID = docType.getPublicID();
String systemID = docType.getSystemID();
String internalSubset = docType.getInternalSubset();
boolean hasPublic = false;
out.write(docType.getElementName());
if (publicID != null) {
  out.write(" PUBLIC \"");
  out.write(" [");
  out.write(currentFormat.lineSeparator);
  out.write(docType.getInternalSubset());
  out.write("]");

代码示例来源:origin: org.jdom/jdom-legacy

public DocType docType(String elementName,
            String publicID, String systemID) {
  return new DocType(elementName, publicID, systemID);
}

代码示例来源:origin: org.freemarker/freemarker

public Object exec(List arguments) {
    Set names = new HashSet(arguments);
    List list = new LinkedList(nodes);
    Iterator it = list.iterator();
    while (it.hasNext()) {
      Object node = it.next();
      String name = null;
      if (node instanceof Element)
        name = ((Element) node).getName();
      else if (node instanceof Attribute)
        name = ((Attribute) node).getName();
      else if (node instanceof ProcessingInstruction)
        name = ((ProcessingInstruction) node).getTarget();
      else if (node instanceof EntityRef)
        name = ((EntityRef) node).getName();
      else if (node instanceof DocType)
        name = ((DocType) node).getPublicID();
      if (name == null || !names.contains(name))
        it.remove();
    }
    return createNodeListModel(list, namespaces);
  }
}

代码示例来源:origin: net.sf.aislib.tools.mapping/library

new DocType("database", "-//AIS.PL//DTD Mapping Description 0.4//EN", "http://www.ais.pl/dtds/mapping_0_4.dtd");
  "<!ENTITY  db_part_" + xmlName + "   SYSTEM \"./" + DB_PARTS_DIR + "/" + xmlName + ".xml\">\n");
docType.setInternalSubset(entities.toString());

代码示例来源:origin: org.freemarker/com.springsource.freemarker

String getLocalName(Object node) {
  if (node instanceof Element) {
    return ((Element)node).getName();
  }
  if (node instanceof Attribute) {
    return ((Attribute)node).getName();
  }
  if (node instanceof EntityRef) {
    return ((EntityRef)node).getName();
  }
  if (node instanceof ProcessingInstruction) {
    return ((ProcessingInstruction)node).getTarget();
  }
  if (node instanceof DocType) {
    return ((DocType)node).getElementName();
  }
  return null;
}

代码示例来源:origin: org.freemarker/freemarker

DocType doctype = (DocType) node;
if ("publicId".equals(localName))
  attr = new Attribute("publicId", doctype.getPublicID());
else if ("systemId".equals(localName))
  attr = new Attribute("systemId", doctype.getSystemID());
else if ("elementName".equals(localName))
  attr = new Attribute("elementName", doctype.getElementName());

代码示例来源:origin: apache/maven-archetype

String publicID = docType.getPublicID();
String systemID = docType.getSystemID();
String internalSubset = docType.getInternalSubset();
boolean hasPublic = false;
out.write( docType.getElementName() );
if ( publicID != null )
  out.write( docType.getInternalSubset() );
  out.write( "]" );

代码示例来源:origin: org.jdom/jdom-legacy

public DocType docType(String elementName) {
  return new DocType(elementName);
}

代码示例来源:origin: org.codehaus.cargo/cargo-core-api-module

/**
 * Returns the version corresponding to the given document type.
 * 
 * @param theDocType The document type
 * @return The version that matches the document type, or <code>null</code> if the doctype is
 * not recognized
 * @throws NullPointerException If the document type is <code>null</code>
 */
public static ApplicationXmlVersion valueOf(DocType theDocType) throws NullPointerException
{
  return valueOf(theDocType.getPublicID());
}

代码示例来源:origin: org.freemarker/freemarker-gae

@Override
String getLocalName(Object node) {
  if (node instanceof Element) {
    return ((Element) node).getName();
  }
  if (node instanceof Attribute) {
    return ((Attribute) node).getName();
  }
  if (node instanceof EntityRef) {
    return ((EntityRef) node).getName();
  }
  if (node instanceof ProcessingInstruction) {
    return ((ProcessingInstruction) node).getTarget();
  }
  if (node instanceof DocType) {
    return ((DocType) node).getElementName();
  }
  return null;
}

代码示例来源:origin: rome/rome

public boolean isMyType(Document document) {
  boolean ok = false;
  Element rssRoot = document.getRootElement();
  ok = rssRoot.getName().equals("rss");
  if (ok) {
    ok = false;
    Attribute version = rssRoot.getAttribute("version");
    if (version!=null) {
      ok = version.getValue().equals(getRSSVersion());
      if (ok) {
        ok = false;
        DocType docType = document.getDocType();
        if (docType!=null) {
          ok = ELEMENT_NAME.equals(docType.getElementName());
          ok = ok && PUBLIC_ID.equals(docType.getPublicID());
          ok = ok && SYSTEM_ID.equals(docType.getSystemID());
        }
      }
    }
  }
  return ok;
}

相关文章