只有当没有价格为 14.95 的书时,我才需要退回所有书......
DTD
<!ELEMENT inventory (book)+>
<!ELEMENT book (title, author+, publisher+, price, chapter*)>
<!ATTLIST book num ID #REQUIRED>
<!ELEMENT chapter (title, (paragraph* | section*))>
<!ELEMENT section (title?, paragraph*)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ATTLIST price currency CDATA #FIXED "usd">
<!ELEMENT paragraph (#PCDATA | emph | image)*>
<!ELEMENT emph (#PCDATA)>
<!ELEMENT image EMPTY >
<!ATTLIST image
file
CDATA #REQUIRED
height CDATA #IMPLIED
width CDATA #IMPLIED >
xml 例如,xml 不受限制是这个
version="1.0" encoding="UTF-8"?>
<!DOCTYPE inventory SYSTEM "books.dtd">
<inventory>
<book num="b1">
<title>Snow Crash</title>
<author>Neal Stephenson</author>
<publisher>Spectra</publisher>
<price>14.95</price>
<chapter>
<title>Snow Crash - Chapter A</title>
<paragraph>
This is the
<emph>first</emph>
paragraph.
<image file="firstParaImage.gif"/>
After image...
</paragraph>
<paragraph>
This is the
<emph>second</emph>
paragraph.
<image file="secondParaImage.gif"/>
After image...
</paragraph>
</section>
</chapter>
</book>
<book num="b3">
<title>Zodiac</title>
<author>Neal Stephenson</author>
<publisher>Spectra</publisher>
<price>7.50</price>
<chapter>
<title>Zodiac - Chapter A</title>
</chapter>
</book>
</inventory>
我知道如何找到所有价格与 14.95 不同的书。但我现在不知道如何在 XPTH 中执行 if 语句,分配仅在 XPTH 中