Which elements in the xml file below should the following xpath match on?
//bk:book[bk:author/bk:first-name='Herman']
I am thinking all three books by Herman Melville should match because 2 of the books have a default namespace, although different in each case, the rule is that the prefix used in the xpath expression to match a default namespace may be arbitrary. The book with the bk namespace should also match because the prefix in the xpath exactly matches the prefixed namespace.
<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xml" href="books.xsl"?>
<bookstore xmlns="http://www.google.com" >
<book>
<title>ASP in a nutshell</title>
</book>
<book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0" xmlns="http://www.yahoo.com"> <title>The Autobiography of Benjamin Franklin</title> <author> <first-name>Benjamin<nickname>Benjy</nickname> </first-name> <last-name>Franklin</last-name> </author> <price>8.99</price> </book> <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2" xmlns="http://www.yahoo.com"> <title>The Confidence Man</title> <author> <first-name>Herman</first-name> <last-name>Melville</last-name> </author> <price>11.99</price> </book> <bk:book bk:genre="novel" bk
ublicationdate="1967-11-17" bk:ISBN="0-201-63361-2" xmlns:bk="c:\temp"> <bk:title>The Confidence Man</bk:title> <bk:author> <bk:first-name>Herman</bk:first-name> <bk:last-name>Melville</bk:last-name> </bk:author> <bk
rice>11.99</bk
rice> </bk:book> <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2"> <title>The Confidence Man</title> <author> <first-name>Herman</first-name> <last-name>Melville</last-name> </author> <price>11.99</price> </book> <book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6"> <title>The Gorgias</title> <author> <name>Plato</name> <fname /> </author> <price>9.99</price> </book> </bookstore>
//bk:book[bk:author/bk:first-name='Herman']
I am thinking all three books by Herman Melville should match because 2 of the books have a default namespace, although different in each case, the rule is that the prefix used in the xpath expression to match a default namespace may be arbitrary. The book with the bk namespace should also match because the prefix in the xpath exactly matches the prefixed namespace.
<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xml" href="books.xsl"?>
<bookstore xmlns="http://www.google.com" >
<book>
<title>ASP in a nutshell</title>
</book>
<book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0" xmlns="http://www.yahoo.com"> <title>The Autobiography of Benjamin Franklin</title> <author> <first-name>Benjamin<nickname>Benjy</nickname> </first-name> <last-name>Franklin</last-name> </author> <price>8.99</price> </book> <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2" xmlns="http://www.yahoo.com"> <title>The Confidence Man</title> <author> <first-name>Herman</first-name> <last-name>Melville</last-name> </author> <price>11.99</price> </book> <bk:book bk:genre="novel" bk