Sorry for the delay in replying.
 
In an expression such as a/b[1], you will get the first b for every a. Similarly, a/ancestor::x[1] selects the first x ancestor of every a. Your example is of the form xxx/subj[1]; but since no element has more than one subj child, the [1] does not affect the outcome.
 
You probably want an expression of the form (xxx/subj)[1].
 
Michael Kay


From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Roger Kovack
Sent: 26 July 2004 23:05
To: saxon-help@lists.sourceforge.net
Subject: Re: [saxon] Numeric predicate in ancestor:: ignored

Would this "unknown type annotation" have to do with the Jdom version? I'm using Jdom beta-9 although you say to use Jdom beta-10. Currently I can't get Jdom beta-10 to work but I don't think that problem has anything to do with Saxon.

Reading your notes on the bug 927957, it looks like it is related to the use of the Jdom wrapper. Is a fixed class or code available? Without that, I don't seem to be able to get Saxon 8 running so I don't know if the problem persists there.

Michael Kay wrote:
Fatal error: Unknown type annotation (NULL) in document instance;
which did not happen in Saxon 7.8. 
 
This looks like bug 927957
http://sourceforge.net/tracker/index.php?func=detail&aid=927057&group_id=29872&atid=397617 

I believe this is refering to a Jdom that is built dynamically from HTTP parameters on each servlet request and passed to Saxon as a parameter, but I'm not sure about this assumption. 
 
I'm afraid without the ability to reproduce the original problem it's difficult for me to track it down, or determine whether it's already fixed. It looks very strange - I can't see any circumstances in which a path expression ending with [1] would deliver more than one node, and the filtering code is not in any way related to the tree model (i.e. the fact that it's a JDOM tree should be irrelevant.
Again, this is a large application and packaging it up and hoping it would run at all for you is problematical. I can live with the work-around of putting the [1] predicate in the copy-of expression if you don't mind not persuing this further. If you do mind, I will certainly send you the whole thing.

However, I have now repeated the failure with a straight Stream source from a file rather than a Jdom source and a number of similar Xpath expressions but still in Saxon 7.8.

Using document:

<task >
   <subj>Master bedroom balcony</subj>
   <task>
      <subj>Construction reqs</subj>
      <task >
         <subj>Framer</subj>
      </task>
   </task>
 </task>

and path: ./task/task/ancestor::task/subj[1]

results:

<subj>Master bedroom balcony</subj>
<subj>Construction reqs</subj>

Let me know if you need the whole application or if this is sufficient.

Thanks for all your help!
Roger Kovack
 
Michael Kay 

Is there a transformer property to disable this behavior?

Thanks,
Roger Kovack

Michael Kay wrote:
Thanks for reporting this. So that I can investigate it, could you please:
 
(a) check whether the problem still exists on Saxon 8.0
 
(b) send me a source file for the XML document used.
 
Michael Kay


From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Roger Kovack
Sent: 25 July 2004 01:36
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Numeric predicate in ancestor:: ignored

This template fragment: ($el-name = 'po')

        <xsl:variable name="src-parent" select="$this-node/ancestor::task/*[name() = $el-name][text() != ''][@decl]"/>
                <xsl:message>src parent: <xsl:copy-of select="$src-parent[1]"/></xsl:message>

reports:
<po decl="">23</po>
which IS the expected results.

But this:

        <xsl:variable name="src-parent" select="$this-node/ancestor::task/*[name() = $el-name][text() != ''][@decl][1]"/>
                <xsl:message>src parent: <xsl:copy-of select="$src-parent"/></xsl:message>

reports:
<po decl="">23</po><po decl="">11</po>
NOT the expected results.

This is running on a JDOM, saxon 7.8

Thanks,
Roger Kovack
------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click _______________________________________________ saxon-help mailing list saxon-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/saxon-help
------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click _______________________________________________ saxon-help mailing list saxon-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/saxon-help
------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click _______________________________________________ saxon-help mailing list saxon-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/saxon-help