本文整理匯總了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 "";
}