From Richard@Netprox.com Sun Jan 21 10:32:10 2001 Return-Path: Mailing-List: contact general-help@xml.apache.org; run by ezmlm Delivered-To: mailing list general@xml.apache.org Received: (qmail 8551 invoked from network); 21 Jan 2001 10:32:10 -0000 Received: from unknown (HELO athena.NETPROX.COM) (212.150.164.50) by h31.sny.collab.net with SMTP; 21 Jan 2001 10:32:10 -0000 Received: by athena.NETPROX.COM with Internet Mail Service (5.5.2650.21) id ; Sun, 21 Jan 2001 12:32:48 +0200 Message-ID: <63D58FB2143B3F48AA7FCFD7DBB61C646A11@athena.NETPROX.COM> From: Richard Toren To: "'general@xml.apache.org'" Subject: RE: how to quickly find an element (by attribute) in a DOM? any h ints appeciated Date: Sun, 21 Jan 2001 12:32:45 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C08395.7F7FFE18" X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N ------_=_NextPart_001_01C08395.7F7FFE18 Content-Type: text/plain; charset="iso-8859-1" Hello, I looked at your DTD with the help of xmlspy and it was brought to my attention that you have the 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: 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 _____ ]> IDEAS Debug Information IDEAS Debug Info ------_=_NextPart_001_01C08395.7F7FFE18 Content-Type: text/html; charset="iso-8859-1"
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>
------_=_NextPart_001_01C08395.7F7FFE18--