Daniel --
Did you ever get this working? If not, please attach your XML document
and the XPath expression that you're using. If you're building the DOM
from other than a text file, change your application to write out the
serialized DOM by including
FileOutputStream fos = new FileOutputStream("mydom.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(myDoc);
oos.flush();
fos.close();
I'll try to reproduce the situation here.
Also, I did notice that in your original note, you specified "(" + eid +
")". If eid is supposed to be a string instead of an XPath expression,
you might want to incude quotes:
"('" + eid + "')"
HTH,
Gary
Daniel Einspanjer wrote:
>
> On Thu, 12 Jul 2001 01:15:09 +0200 (CEST), Erwin Bolwidt wrote:
> >On Wed, 11 Jul 2001, Daniel Einspanjer wrote:
> >
> >> I have been struggling with trying to get the XPath id() function to
> >> work in the application I am writting. I have a DTD that defines an ID
> >> attribute and an xslt that performs some custom html translation.
> >> During runtime, I load the xml document using the
> >> org.apache.xerces.DOMParser, and the XPathAPI.selectNodeList() method to
> >> find the node I want. Unfortunately, I am having to use the XPath
> >> "//element[@ID='" + eid + "']" instead of "id(" + eid + ")". There are
> >> two problems with this. First, it is slow on large documents, and
> >> second, I have to have a large if nest to keep trying different elements
> >> until I find the one that matches.
> >>
> >> Has *anyone* done anything with DTD id attributes in Xalan? Could
> >> someone spare a moment to give me a pointer or maybe even an example?
> >
> >I've included two small files in which the id() function is used in an xsl
> >stylesheet, and it works.
> >
> >I run:
> >java -jar ../../xalan-j_2_1_0/bin/xalan.jar -IN test.xml -XSL test1.xsl
> >
> >It was necessary to declare the attribute that serves as an id as type ID
> >(see test.xml) If you did that, perhaps this attribute information is
> >not passed (correctly) to xalan through the DOM tree for some reason.
> >
> >The id() function should look through the whole document in which the
> >context node of the xpath expression appears. What do you pass to
> >selectNodeList as the context node?
> >
> >Regards,
> > Erwin
> >
>
> I was not clear enough in my first e-mail. Part of my frustration with
> all of this is that I found that the id() function worked fine in xsl
> transformations, but I couldn't get it to work when using the DOM and
> XPathAPI in my code to manipulate the xml file. For instance, to find
> one element in the document (by its id) and do something with it.
>
> For instance, in the xalan package, there is an example called
> ApplyXPath. It takes an XPath statement as an expression. What I need
> to be able to do is to be able to apply the id() function using ApplyXPath.
> The XPathAPI has code to handle this function, but I can't make it return
> anything. It will run without error, but the node in question is not found.
>
> Thanks for the reply!
> -- Daniel Einspanjer, [EMAIL PROTECTED] on 07/12/2001