javax.xml.stream.events.DTD类的使用及代码示例

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

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

DTD介绍

[英]This is the top level interface for events dealing with DTDs
[中]这是处理DTD的事件的顶级接口

代码示例

代码示例来源:origin: spring-projects/spring-framework

private void handleDtd(DTD dtd) throws SAXException {
  if (getLexicalHandler() != null) {
    javax.xml.stream.Location location = dtd.getLocation();
    getLexicalHandler().startDTD(null, location.getPublicId(), location.getSystemId());
  }
  if (getLexicalHandler() != null) {
    getLexicalHandler().endDTD();
  }
}

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

final DocType dtype = DTDParser.parse(((javax.xml.stream.events.DTD)event).getDocumentTypeDeclaration(), factory);
  document.setDocType(dtype);
} else if (event.isStartElement()) {
} else if (event.isCharacters()) {
  final Characters chars = event.asCharacters();
  if (chars.isCData()) {
    current.addContent(factory.cdata(
        ((Characters)event).getData()));
  } else {
    current.addContent(factory.text(
        ((Characters)event).getData()));
      ((javax.xml.stream.events.Comment)event).getText());
  if (current == null) {
    document.addContent(comment);
} else if (event.isProcessingInstruction()) {
  final ProcessingInstruction pi = factory.processingInstruction(
      ((javax.xml.stream.events.ProcessingInstruction)event).getTarget(),
      ((javax.xml.stream.events.ProcessingInstruction)event).getData());
  if (current == null) {
    document.addContent(pi);

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

Characters chars = fCurrentEvent.asCharacters();
    fStAXValidatorHandler.setIgnoringCharacters(true);
    sendCharactersToValidator(chars.getData());
    fStAXValidatorHandler.setIgnoringCharacters(false);
    fStAXValidatorHandler.characters(chars);
    sendCharactersToValidator(fCurrentEvent.asCharacters().getData());
    fStAXValidatorHandler.setIgnoringCharacters(true);
    fSchemaValidator.startCDATA(null);
    sendCharactersToValidator(fCurrentEvent.asCharacters().getData());
    fSchemaValidator.endCDATA(null);
    fStAXValidatorHandler.setIgnoringCharacters(false);
    fillXMLString(fTempString, pi.getData());
    fSchemaValidator.processingInstruction(pi.getTarget(), fTempString, null);
    fillXMLString(fTempString, c.getText());
    fSchemaValidator.comment(fTempString, null);
case XMLStreamConstants.DTD:
  DTD dtd = (DTD) fCurrentEvent;
  processEntityDeclarations(dtd.getEntities());
  if (fStAXValidatorHandler != null) {
    fStAXValidatorHandler.doctypeDecl(dtd);

代码示例来源:origin: org.apache.santuario/xmlsec

@Override
public int getTextLength() {
  XMLSecEvent xmlSecEvent = getCurrentEvent();
  switch (xmlSecEvent.getEventType()) {
    case ENTITY_REFERENCE:
      return ((EntityReference) xmlSecEvent).getDeclaration().getReplacementText().length();
    case DTD:
      return ((DTD) xmlSecEvent).getDocumentTypeDeclaration().length();
    case COMMENT:
      return ((Comment) xmlSecEvent).getText().length();
    case CDATA:
    case SPACE:
    case CHARACTERS:
      return xmlSecEvent.asCharacters().getData().length();
    default:
      throw new IllegalStateException("Current state not TEXT");
  }
}

代码示例来源:origin: net.java.dev.stax-utils/stax-utils

/**
 * Compares two {@link DTD}s. This method will return <code>true</code>
 * only if their declarations are identical.
 * 
 * @param a The first event.
 * @param b The second event.
 * @return <code>true</code> if the events match, <code>false</code> otherwise.
 */
public static boolean eventsMatch(DTD a, DTD b) {
  if (a == b) {
    return true;
  } else if (a == null || a == null) {
    return false;
  } else {
    // TODO determine the best way to compare DTD events
    return a.getDocumentTypeDeclaration().equals(
        b.getDocumentTypeDeclaration());
  }
}

代码示例来源:origin: net.java.dev.stax-utils/stax-utils

/** Copy constructor. */
public DTDEvent(DTD that) {
  super(that);
  this.declaration = that.getDocumentTypeDeclaration();
  this.entities = that.getEntities();
  this.notations = that.getNotations();
}

代码示例来源:origin: com.caucho/resin

public boolean equals(Object o) 
 {
  if (! (o instanceof DTD))
   return false;
  if (o == null)
   return false;
  if (this == o)
   return true;

  DTD dtd = (DTD) o;

  return 
   getDocumentTypeDeclaration().equals(dtd.getDocumentTypeDeclaration()) &&
   getEntities().equals(dtd.getEntities()) &&
   getNotations().equals(dtd.getNotations()) &&
   getProcessedDTD().equals(dtd.getProcessedDTD());
 }
}

代码示例来源:origin: beckchr/staxon

case XMLStreamConstants.CDATA:
  Characters characters = event.asCharacters();
  if (characters.isCData()) {
    delegate.writeCData(characters.getData());
  } else {
    delegate.writeCharacters(characters.getData());
  delegate.writeComment(((Comment) event).getText());
  break;
case XMLStreamConstants.DTD:
  delegate.writeDTD(((DTD) event).getDocumentTypeDeclaration());
  break;
case XMLStreamConstants.ENTITY_REFERENCE:
case XMLStreamConstants.PROCESSING_INSTRUCTION:
  ProcessingInstruction processingInstruction = (ProcessingInstruction) event;
  delegate.writeProcessingInstruction(processingInstruction.getTarget(), processingInstruction.getData());
  break;
case XMLStreamConstants.SPACE:

代码示例来源:origin: org.apache.santuario/xmlsec

@Override
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException {
  XMLSecEvent xmlSecEvent = getCurrentEvent();
  switch (xmlSecEvent.getEventType()) {
    case ENTITY_REFERENCE:
      ((EntityReference) xmlSecEvent).getDeclaration().getReplacementText().getChars(sourceStart, sourceStart + length, target, targetStart);
      return length;
    case DTD:
      ((DTD) xmlSecEvent).getDocumentTypeDeclaration().getChars(sourceStart, sourceStart + length, target, targetStart);
      return length;
    case COMMENT:
      ((Comment) xmlSecEvent).getText().getChars(sourceStart, sourceStart + length, target, targetStart);
      return length;
    case CDATA:
    case SPACE:
    case CHARACTERS:
      xmlSecEvent.asCharacters().getData().getChars(sourceStart, sourceStart + length, target, targetStart);
      return length;
    default:
      throw new IllegalStateException("Current state not TEXT");
  }
}

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

public void addDTD(DTD dtd)
 throws XMLStreamException
{
 writer.writeDTD(dtd.getDocumentTypeDeclaration());
}

代码示例来源:origin: wso2/wso2-synapse

case XMLStreamConstants.CDATA:
  Characters characters = event.asCharacters();
  if (characters.isCData()) {
    delegate.writeCData(characters.getData());
  } else {
    delegate.writeCharacters(characters.getData());
  delegate.writeComment(((Comment) event).getText());
  break;
case XMLStreamConstants.DTD:
  delegate.writeDTD(((DTD) event).getDocumentTypeDeclaration());
  break;
case XMLStreamConstants.ENTITY_REFERENCE:
case XMLStreamConstants.PROCESSING_INSTRUCTION:
  ProcessingInstruction processingInstruction = (ProcessingInstruction) event;
  delegate.writeProcessingInstruction(processingInstruction.getTarget(), processingInstruction.getData());
  break;
case XMLStreamConstants.SPACE:

代码示例来源:origin: org.apache.santuario/xmlsec

@Override
public char[] getTextCharacters() {
  XMLSecEvent xmlSecEvent = getCurrentEvent();
  switch (xmlSecEvent.getEventType()) {
    case ENTITY_REFERENCE:
      return ((EntityReference) xmlSecEvent).getDeclaration().getReplacementText().toCharArray();
    case DTD:
      return ((DTD) xmlSecEvent).getDocumentTypeDeclaration().toCharArray();
    case COMMENT:
      return ((Comment) xmlSecEvent).getText().toCharArray();
    case CDATA:
    case SPACE:
    case CHARACTERS:
      return xmlSecEvent.asCharacters().getText();
    default:
      throw new IllegalStateException("Current state not TEXT");
  }
}

代码示例来源:origin: net.java.dev.stax-utils/stax-utils

/**
 * Writes a {@link DTD} to the provided stream.
 * 
 * @param dtd The {@link DTD} to write.
 * @param writer The destination stream.
 * @throws XMLStreamException If an error occurs writing to the stream.
 */
public static final void writeDTD(DTD dtd, XMLStreamWriter writer)
    throws XMLStreamException {
  writer.writeDTD(dtd.getDocumentTypeDeclaration());
}

代码示例来源:origin: org.springframework/spring-core

private void handleDtd(DTD dtd) throws SAXException {
  if (getLexicalHandler() != null) {
    javax.xml.stream.Location location = dtd.getLocation();
    getLexicalHandler().startDTD(null, location.getPublicId(), location.getSystemId());
  }
  if (getLexicalHandler() != null) {
    getLexicalHandler().endDTD();
  }
}

代码示例来源:origin: org.wso2.staxon/staxon

case XMLStreamConstants.CDATA:
  Characters characters = event.asCharacters();
  if (characters.isCData()) {
    delegate.writeCData(characters.getData());
  } else {
    delegate.writeCharacters(characters.getData());
  delegate.writeComment(((Comment) event).getText());
  break;
case XMLStreamConstants.DTD:
  delegate.writeDTD(((DTD) event).getDocumentTypeDeclaration());
  break;
case XMLStreamConstants.ENTITY_REFERENCE:
case XMLStreamConstants.PROCESSING_INSTRUCTION:
  ProcessingInstruction processingInstruction = (ProcessingInstruction) event;
  delegate.writeProcessingInstruction(processingInstruction.getTarget(), processingInstruction.getData());
  break;
case XMLStreamConstants.SPACE:

代码示例来源:origin: org.apache.santuario/xmlsec

@Override
public String getText() {
  XMLSecEvent xmlSecEvent = getCurrentEvent();
  switch (xmlSecEvent.getEventType()) {
    case ENTITY_REFERENCE:
      return ((EntityReference) xmlSecEvent).getDeclaration().getReplacementText();
    case DTD:
      return ((DTD) xmlSecEvent).getDocumentTypeDeclaration();
    case COMMENT:
      return ((Comment) xmlSecEvent).getText();
    case CDATA:
    case SPACE:
    case CHARACTERS:
      return xmlSecEvent.asCharacters().getData();
    default:
      throw new IllegalStateException("Current state not TEXT");
  }
}

代码示例来源:origin: net.sf.okapi.filters/okapi-filter-ts

private void procDTD(XMLEvent event) {
  DTD dtd = (DTD) event;
  skel.append(dtd.getDocumentTypeDeclaration().replace("\n", lineBreak));
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void handleDtd(DTD dtd) throws SAXException {
  if (getLexicalHandler() != null) {
    javax.xml.stream.Location location = dtd.getLocation();
    getLexicalHandler().startDTD(null, location.getPublicId(), location.getSystemId());
  }
  if (getLexicalHandler() != null) {
    getLexicalHandler().endDTD();
  }
}

代码示例来源:origin: com.caucho/resin

Characters characters = (Characters) event;
switch (characters.getEventType()) {
 case CDATA:
  _out.writeCData(characters.getData());
  break;
 case CHARACTERS: 
 default:
  _out.writeCharacters(characters.getData());
  break;
Comment comment = (Comment) event;
_out.writeComment(comment.getText());
_out.writeDTD(dtd.getDocumentTypeDeclaration());
ProcessingInstruction pi = (ProcessingInstruction) event;
if (pi.getData() == null || "".equals(pi.getData()))
 _out.writeProcessingInstruction(pi.getTarget());
else
 _out.writeProcessingInstruction(pi.getTarget(), pi.getData());

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

public void doctypeDecl(DTD event) throws XMLStreamException {
  fStreamWriter.writeDTD(event.getDocumentTypeDeclaration());
}

相关文章