In a XML file Some entity are declared
for exp:
<?xml version="1.0" encoding="utf-8"?>
<!--Arbortext, Inc., 1988-2004, v.4002-->
<!DOCTYPE test PUBLIC "-//Atul//DTD ATM - TEST//EN//-"
"test.dtd" [
<!ENTITY ent1 SYSTEM "Graphic/test1.txt" NDATA ccitt4>
<!ENTITY ent1 SYSTEM "Graphic/test1.txt" NDATA ccitt4>
<!ENTITY ent2 SYSTEM "Graphic/test2.txt" NDATA ccitt4>
<!ENTITY ent3 SYSTEM "Graphic/test4.txt" NDATA ccitt4>
]>
<test id="01" >
</test>
I Have to find that ent1 is declared more than once .
For the moment we are using getEntities method
NamedNodeMap entities = lJDocumentXML.getDoctype().getEntities();
http://docs.oracle.com/javase/7/docs/api/org/w3c/dom/DocumentType.html#getEntities()
Which do not returns duplicate entity (it returns only ent1 ,ent2 and ent3) and external entity if any in the referenced dtd
Is there any way to get all the four entities ?
Thanks Atul
"DocumentType" discard duplicates of attributes "entities" and "notations" by Interface Definition (see W3C DOM Spec. W3C SPEC - REC-DOM-Level-3-Core)
A NamedNodeMap containing the general entities, both external and internal, declared in the DTD. Parameter entities are not contained. Duplicates are discarded. For example in:
<!DOCTYPE ex SYSTEM "ex.dtd" [ <!ENTITY foo "foo"> <!ENTITY bar "bar"> <!ENTITY bar "bar2"> <!ENTITY % baz "baz"> ]> <ex/>the interface provides access to foo and the first declaration of bar but not the second declaration of bar or baz. Every node in this map also implements the Entity interface. The DOM Level 2 does not support editing entities, therefore entities cannot be altered in any way.
I think that you need to use another method to parse/check this information... e.g. you can use a regular expression.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With