You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Richard Toren <Ri...@Netprox.com> on 2001/01/21 11:32:45 UTC

RE: how to quickly find an element (by attribute) in a DOM? any h ints appeciated

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>



Re: how to quickly find an element (by attribute) in a DOM? any hints appeciated

Posted by "Thomas B. Passin" <tp...@mitretek.org>.
Actually, it's not an error to declare an element twice. The first declaration wins and the later one(s) are ignored.  However, in this case it may not give the intended result.

Tom Passin

Richard Toren wrote -
  To: 'general@xml.apache.org' 
  Sent: Sunday, January 21, 2001 5:32 AM
  Subject: RE: how to quickly find an element (by attribute) in a DOM? any hints appeciated


  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:



processStylesheet

Posted by Lyle Coder <x_...@hotmail.com>.
Hello,
Can I call XSLTProcessor::processStylesheet() in the beginning of my program and actually call XSLTProcessor::process() at some later time in my program?  In other words... is this legal:

a = XSLTProcess::processStylesheet()
b = XSLTProcess::processStylesheet()
... /* some thing else */

XSLTProcessor::process(a);
XSLTProcessor::reset();

/* some thing else */

XSLTProcessor::process(b);
XSLTProcessor::reset();

Thanks
Lyle