本文整理汇总了Java中org.w3c.dom.Notation类的典型用法代码示例。如果您正苦于以下问题:Java Notation类的具体用法?Java Notation怎么用?Java Notation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Notation类属于org.w3c.dom包,在下文中一共展示了Notation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: declareNotation
import org.w3c.dom.Notation; //导入依赖的package包/类
/**
* Records the declaration of a notation in this DocumentType.
*
* @param name Name of the notation
* @param publicId If non-null, provides the notation's PUBLIC identifier
* @param systemId If non-null, provides the notation's SYSTEM identifier
* @return The notation that was declared.
*
* @exception DOMException NO_MODIFICATION_ALLOWED_ERR if the
* DocumentType is no longer writable.
* @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType
* is not associated with a document.
*/
public Notation declareNotation(String name,
String publicId,
String systemId)
{
DomNotation notation;
if (isReadonly())
{
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
}
getNotations();
DomDocument.checkName(name, (owner != null) ?
"1.1".equals(owner.getXmlVersion()) : false);
notation = new DomNotation(owner, name, publicId, systemId);
notations.setNamedItem(notation);
return notation;
}
示例2: declareNotation
import org.w3c.dom.Notation; //导入依赖的package包/类
/**
* Records the declaration of a notation in this DocumentType.
*
* @param name Name of the notation
* @param publicId If non-null, provides the notation's PUBLIC identifier
* @param systemId If non-null, provides the notation's SYSTEM identifier
* @return The notation that was declared.
*
* @exception DOMException NO_MODIFICATION_ALLOWED_ERR if the
* DocumentType is no longer writable.
* @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType
* is not associated with a document.
*/
public Notation declareNotation(String name,
String publicId,
String systemId)
{
DomNotation notation;
if (isReadonly())
{
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
}
getNotations();
DomDocument.checkName(name, (owner != null) ?
"1.1".equals(owner.getXmlVersion()) : false);
notation = new DomNotation(owner, name, publicId, systemId);
notations.setNamedItem(notation);
return notation;
}
示例3: visitNode
import org.w3c.dom.Notation; //导入依赖的package包/类
static <R> R visitNode(Node node, NodeVisitor<R> visitor) {
switch (node.getNodeType()) {
case Node.ELEMENT_NODE: return visitor.visitElement((Element) node);
case Node.ATTRIBUTE_NODE: return visitor.visitAttr((Attr) node);
case Node.TEXT_NODE: return visitor.visitText((Text) node);
case Node.CDATA_SECTION_NODE: return visitor.visitCDATASection((CDATASection) node);
case Node.ENTITY_REFERENCE_NODE: return visitor.visitEntityReference((EntityReference) node);
case Node.ENTITY_NODE: return visitor.visitEntity((Entity) node);
case Node.PROCESSING_INSTRUCTION_NODE:
return visitor.visitProcessingInstruction((ProcessingInstruction) node);
case Node.COMMENT_NODE: return visitor.visitComment((Comment) node);
case Node.DOCUMENT_NODE: return visitor.visitDocument((Document) node);
case Node.DOCUMENT_TYPE_NODE: return visitor.visitDocumentType((DocumentType) node);
case Node.DOCUMENT_FRAGMENT_NODE:
return visitor.visitDocumentFragment((DocumentFragment) node);
case Node.NOTATION_NODE: return visitor.visitNotation((Notation) node);
default: throw new RuntimeException();
}
}
示例4: enter
import org.w3c.dom.Notation; //导入依赖的package包/类
public boolean enter(Notation notation) {
String name = notation.getNodeName();
String pubId = notation.getPublicId();
String sysId = notation.getSystemId();
buffer.append("<!NOTATION ");
buffer.append(name);
if (pubId != null) {
buffer.append(" PUBLIC \"");
buffer.append(pubId);
buffer.append("\"");
if (sysId != null) {
buffer.append(" \"");
buffer.append(sysId);
buffer.append("\"");
}
} else if (sysId != null) {
buffer.append(" SYSTEM \"");
buffer.append(sysId);
buffer.append("\"");
}
buffer.append(">");
return true;
}
示例5: doctypeDecl
import org.w3c.dom.Notation; //导入依赖的package包/类
public void doctypeDecl(DocumentType node) throws XNIException {
/** Create new DocumentType node for the target. */
if (fDocumentImpl != null) {
DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId());
final String internalSubset = node.getInternalSubset();
/** Copy internal subset. */
if (internalSubset != null) {
((DocumentTypeImpl) docType).setInternalSubset(internalSubset);
}
/** Copy entities. */
NamedNodeMap oldMap = node.getEntities();
NamedNodeMap newMap = docType.getEntities();
int length = oldMap.getLength();
for (int i = 0; i < length; ++i) {
Entity oldEntity = (Entity) oldMap.item(i);
EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName());
newEntity.setPublicId(oldEntity.getPublicId());
newEntity.setSystemId(oldEntity.getSystemId());
newEntity.setNotationName(oldEntity.getNotationName());
newMap.setNamedItem(newEntity);
}
/** Copy notations. */
oldMap = node.getNotations();
newMap = docType.getNotations();
length = oldMap.getLength();
for (int i = 0; i < length; ++i) {
Notation oldNotation = (Notation) oldMap.item(i);
NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName());
newNotation.setPublicId(oldNotation.getPublicId());
newNotation.setSystemId(oldNotation.getSystemId());
newMap.setNamedItem(newNotation);
}
append(docType);
}
}
示例6: isIgnorableNode
import org.w3c.dom.Notation; //导入依赖的package包/类
/**
* Bepaal of de gegeven node genegeerd kan worden.
* @param node node
* @return true, als de node genegeerd kan worden, anders false
*/
public static boolean isIgnorableNode(final Node node) {
boolean result = false;
if (node instanceof Comment || node instanceof Notation || node instanceof ProcessingInstruction) {
// Commentaar, etc kan genegeerd worden
result = true;
}
if (node instanceof Text && node.getTextContent().trim().isEmpty()) {
// Lege text kan genegeerd worden
result = true;
}
if (node instanceof Attr) {
if (node.getNodeName().startsWith("xmlns")) {
// Alles met namespaces wordt genegeerd
result = true;
}
if ("class".equals(node.getLocalName())) {
// Class identificatie wordt door het framework gebruikt.
result = true;
}
}
return result;
}
示例7: createNotation
import org.w3c.dom.Notation; //导入依赖的package包/类
/**
* NON-DOM Factory method; creates a Notation having this Document as its
* OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD
* information unspecified.)
*
* @param name The name of the Notation we wish to describe
*
* @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where
* notations are not permitted. (HTML not yet implemented.)
*/
public Notation createNotation(String name)
throws DOMException {
if (errorChecking && !isXMLName(name, xml11Version)) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
}
return new NotationImpl(this, name);
}
示例8: findNotation
import org.w3c.dom.Notation; //导入依赖的package包/类
private Notation findNotation(String name) throws SAXException, IOException, ParserConfigurationException {
Document document = createDOM("Notation01.xml");
NamedNodeMap nm = document.getDoctype().getNotations();
for (int i = 0; i < nm.getLength(); i++) {
if (nm.item(i).getNodeName().equals(name)) {
return (Notation) nm.item(i);
}
}
throw new RuntimeException("Notation: '" + name + "' not found.");
}
示例9: evaluate
import org.w3c.dom.Notation; //导入依赖的package包/类
@Override
public Object evaluate(Node context, int pos, int len)
{
int arity = args.size();
List<Object> values = new ArrayList<Object>(arity);
for (int i = 0; i < arity; i++)
{
Expr arg = args.get(i);
values.add(arg.evaluate(context, pos, len));
}
String name = _string(context, values.get(0));
DocumentType doctype = context.getOwnerDocument().getDoctype();
if (doctype != null)
{
NamedNodeMap notations = doctype.getNotations();
Notation notation = (Notation) notations.getNamedItem(name);
if (notation != null)
{
String systemId = notation.getSystemId();
// XXX absolutize?
if (systemId != null)
{
return systemId;
}
}
}
return "";
}
示例10: testNode
import org.w3c.dom.Notation; //导入依赖的package包/类
/**
* Validate a single Node by delegating to node type specific methods.
* @see #testAttribute(Attr)
* @see #testCDATASection(CDATASection)
* @see #testComment(Comment)
* @see #testDocumentType(DocumentType)
* @see #testElement(Element)
* @see #testEntity(Entity)
* @see #testEntityReference(EntityReference)
* @see #testNotation(Notation)
* @see #testProcessingInstruction(ProcessingInstruction)
* @see #testText(Text)
*/
public void testNode(Node aNode, NodeTest forTest) throws NodeTestException {
switch (aNode.getNodeType()) {
case Node.ATTRIBUTE_NODE:
// should not happen as attributes are not exposed by DOM traversal
testAttribute((Attr)aNode);
break;
case Node.CDATA_SECTION_NODE:
testCDATASection((CDATASection)aNode);
break;
case Node.COMMENT_NODE:
testComment((Comment)aNode);
break;
case Node.DOCUMENT_TYPE_NODE:
testDocumentType((DocumentType)aNode);
break;
case Node.ELEMENT_NODE:
testElement((Element)aNode);
break;
case Node.ENTITY_NODE:
testEntity((Entity)aNode);
break;
case Node.ENTITY_REFERENCE_NODE:
testEntityReference((EntityReference)aNode);
break;
case Node.NOTATION_NODE:
testNotation((Notation)aNode);
break;
case Node.PROCESSING_INSTRUCTION_NODE:
testProcessingInstruction(
(ProcessingInstruction) aNode);
break;
case Node.TEXT_NODE:
testText((Text)aNode);
break;
default:
throw new NodeTestException("No delegate method for Node type",
aNode);
}
}
示例11: encodeHeader
import org.w3c.dom.Notation; //导入依赖的package包/类
private void encodeHeader(Document d) throws IOException {
List<UnparsedEntity> unParsedEntities = null;
List<fastinfoset.Document.Notation> notations = null;
DocumentType docType = d.getDoctype();
if (docType != null) {
//Notations
notations = getNotations(docType.getNotations());
//Unparsed Entities
unParsedEntities = getUnparsedEntities(docType.getEntities());
}
encodeHeader(d.getXmlEncoding(), d.getXmlStandalone(), d.getXmlVersion(), unParsedEntities, notations);
}
示例12: getNotations
import org.w3c.dom.Notation; //导入依赖的package包/类
private List<fastinfoset.Document.Notation> getNotations(NamedNodeMap notations) {
List<fastinfoset.Document.Notation> result = new ArrayList<fastinfoset.Document.Notation>();
for (int i = 0; i < notations.getLength(); i++) {
Notation n = (Notation) notations.item(i);
result.add(new fastinfoset.Document.Notation(n.getNodeName(), n.getSystemId(), n.getPublicId()));
}
return result;
}
示例13: createNotation
import org.w3c.dom.Notation; //导入依赖的package包/类
/**
* NON-DOM Factory method; creates a Notation having this Document as its OwnerDoc. (REC-DOM-Level-1-19981001 left
* the process of building DTD information unspecified.)
*
* @param name The name of the Notation we wish to describe
*
* @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where notations are not permitted. (HTML not yet
* implemented.)
*/
public Notation createNotation(String name) throws DOMException {
if (errorChecking && !isXMLName(name, xml11Version)) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR",
null);
throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
}
return new NotationImpl(this, name);
}
示例14: visitNotation
import org.w3c.dom.Notation; //导入依赖的package包/类
@Override public R visitNotation(Notation node) {
return visitDefault(node);
}
示例15: setUp
import org.w3c.dom.Notation; //导入依赖的package包/类
@Override protected void setUp() throws Exception {
transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
builder = factory.newDocumentBuilder();
domImplementation = builder.getDOMImplementation();
document = builder.parse(new InputSource(new StringReader(xml)));
// doctype nodes
doctype = document.getDoctype();
if (doctype.getEntities() != null) {
sp = (Entity) doctype.getEntities().item(0);
}
if (doctype.getNotations() != null) {
png = (Notation) doctype.getNotations().item(0);
}
// document nodes
menu = document.getDocumentElement();
item = (Element) menu.getChildNodes().item(1);
itemXmlns = item.getAttributeNode("xmlns");
itemXmlnsA = item.getAttributeNode("xmlns:a");
name = (Element) item.getChildNodes().item(1);
standard = name.getAttributeNode("a:standard");
deluxe = name.getAttributeNode("deluxe");
waffles = (Text) name.getChildNodes().item(0);
description = (Element) item.getChildNodes().item(3);
descriptionText1 = (Text) description.getChildNodes().item(0);
descriptionText2 = (CDATASection) description.getChildNodes().item(1);
descriptionText3 = (Text) description.getChildNodes().item(2);
option1 = (Element) item.getChildNodes().item(5);
option2 = (Element) item.getChildNodes().item(7);
option2Reference = option2.getChildNodes().item(0);
wafflemaker = (ProcessingInstruction) item.getChildNodes().item(9);
nutrition = (Element) item.getChildNodes().item(11);
vitamins = (Element) nutrition.getChildNodes().item(1);
vitaminsXmlnsA = vitamins.getAttributeNode("xmlns:a");
comment = (Comment) vitamins.getChildNodes().item(1);
vitaminc = (Element) vitamins.getChildNodes().item(3);
vitamincText = (Text) vitaminc.getChildNodes().item(0);
allNodes = new ArrayList<Node>();
if (sp != null) {
allNodes.add(sp);
}
if (png != null) {
allNodes.add(png);
}
allNodes.addAll(Arrays.asList(document, doctype, menu, item, itemXmlns,
itemXmlnsA, name, standard, deluxe, waffles, description,
descriptionText1, descriptionText2, descriptionText3, option1,
option2, option2Reference, wafflemaker, nutrition, vitamins,
vitaminsXmlnsA, comment, vitaminc, vitamincText));
}