xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Toren <Rich...@Netprox.com>
Subject RE: how to quickly find an element (by attribute) in a DOM? any h ints appeciated
Date Sun, 21 Jan 2001 10:32:45 GMT
Hello,
   I looked at your DTD with the help of xmlspy and it was brought to my
attention that  you have the <!ELEMENT event ..... > defined twice.  This is
probably unintentional, but definitely is an error.  Secondly, I think that
a valid ID must start with an alpha and that no two nodes share the same id.
Now to your question:
 
<xsl:template="id('myID')">
   <xsl:copy-of select="." />
<xsl:template>
 
will copy the selected id along with it's children.  Hope this helps.
 
Richard

-----Original Message-----
From: Gerry Haustein [mailto:gdh1@osi.com]
Sent: Saturday, January 20, 2001 2:48 AM
To: general@xml.apache.org
Subject: how to quickly find an element (by attribute) in a DOM? any hints
appeciated


Anyone know how to do this?
 
Given an element name, an attribute name and optionally an attribute value:
what is the best way to quickly find that element in the DOM?
 
We have tryed getElementsByTagName (then searched the resulting list for
attributes) but that turns out to be too slow.
 
Next we tryed using the special "ID" thing that can be used in DTDs, but
xerces then failed to load the document. Our XML/DTD loads okay unless we
try to specify ID in the DTD (as documented in our Wrox book).
 
thanks for any help,
Gerry
 

  _____  

 
<?xml version="1.0"?>
<!DOCTYPE debugDocument [
<!ELEMENT debugDocument (name,description,events)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT events (event)*>
<!ELEMENT event (#PCDATA)>
<!ATTLIST event id ID #REQUIRED>
<!ATTLIST event name CDATA #REQUIRED>
<!ATTLIST event class CDATA #REQUIRED>
<!ELEMENT event (rules)>
<!ELEMENT rules (rule)*>
<!ELEMENT rule (#PCDATA)>
<!ATTLIST rule op CDATA #REQUIRED>
<!ATTLIST rule op1 CDATA #REQUIRED>
<!ATTLIST rule op2 CDATA #REQUIRED>
<!ATTLIST rule alert CDATA #REQUIRED>
<!ATTLIST rule event CDATA #REQUIRED>
<!ATTLIST rule lineNo CDATA #REQUIRED>
<!ATTLIST rule relate CDATA #REQUIRED>
]>
<debugDocument>
   <name>IDEAS Debug Information</name>
   <description>IDEAS Debug Info</description>
   <events>
   <event id="1" name="" class="">
  <rules>
  <rule op="" op1="" op2="" alert="" event="" lineNo="" relate="">
  </rule>
  </rules>
   </event>
   </events>
</debugDocument>



Mime
View raw message