You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Wei Cheng <We...@baylor.edu> on 2000/11/14 00:21:26 UTC
One Question about ApplyXapth
Hi All,
When I change the ApplyXpath's argumnets to the following:
foo.xml /doc/name[@first="David"]
It don't give the proper answer.
select all name children of the context node that have a
type attribute with a value "David"
also, I changed foo.xml a little to foo1.xml as following:
<?xml version="1.0"?>
<doc>
<name>
<firstname> David </firstname>
<lastname> Marston</lastname>
</name>
<name>
<firstname> David </firstname>
<lastname> Bertoni </lastname>
</name>
<name>
<firstname> Donald </firstname>
<lastname> Leslie </lastname>
</name>
<name>
<firstname> Emily </firstname>
<lastname> Farmer </lastname>
</name>
<name>
<firstname> Jack </firstname>
<lastname> Donohue</lastname>
</name>
<name>
<firstname> Myriam </firstname>
<lastname> Midy</lastname>
</name>
<name>
<firstname> Paul </firstname>
<lastname> Dick</lastname>
</name>
<name>
<firstname> Robert </firstname>
<lastname> Weir</lastname>
</name>
<name>
<firstname> Scott </firstname>
<lastname> Boag</lastname>
</name>
<name>
<firstname> Shane </firstname>
<lastname> Curcuru</lastname>
</name>
</doc>
When I apply foo.xml /doc/name[firstname="David"]
I still can't get the right answer.
I use this syntax from w3.org,
another question, in the documention of w3.org/TR/XPath
17's page, there is a NOTE :
says not($x!="foo")
I had a similar idea to apply this to check whether the xml
document satisfy the foreign key.
I created another foo2.xml
<?xml version="1.0"?>
<doc>
<person>
<name>
<firstname> David </firstname>
<lastname> Marston</lastname>
</name>
<age> 42 </age>
</person>
<person>
<name>
<firstname> Donald </firstname>
<lastname> Leslie </lastname>
</name>
<age> 40 </age>
</person>
<person>
<name>
<firstname> Emily </firstname>
<lastname> Farmer </lastname>
</name>
<age> 30 </age>
</person>
<person>
<name>
<firstname> Jack </firstname>
<lastname> Donohue</lastname>
</name>
<age> 35 </age>
</person>
<person>
<name>
<firstname> Myriam </firstname>
<lastname> Midy</lastname>
</name>
<age> 33 </age>
</person>
</doc>
and want to check if name is a foreign key in foo2.xml,
I want to compare foo2.xml name nodeset with foo1.xml name
nodeset.
How can I specify this is xpath?
my idea is not($name(from foo2.xml)!=$name(from foo1.xml))
thanks!
Best regards,
Wei mailto:Wei_Cheng@baylor.edu