本文整理汇总了Java中org.w3c.dom.DocumentType.getNotations方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentType.getNotations方法的具体用法?Java DocumentType.getNotations怎么用?Java DocumentType.getNotations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.DocumentType
的用法示例。
在下文中一共展示了DocumentType.getNotations方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doctypeDecl
import org.w3c.dom.DocumentType; //导入方法依赖的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);
}
}
示例2: testGetNotations
import org.w3c.dom.DocumentType; //导入方法依赖的package包/类
@Test
public void testGetNotations() throws Exception {
DocumentType documentType = createDOM("DocumentType03.xml").getDoctype();
NamedNodeMap nm = documentType.getNotations();
assertEquals(nm.getLength(), 2); // should return 2 because the notation
// name is repeated and
// it considers only the first
// occurence
assertEquals(nm.item(0).getNodeName(), "gs");
assertEquals(nm.item(1).getNodeName(), "name");
}
示例3: evaluate
import org.w3c.dom.DocumentType; //导入方法依赖的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 "";
}