M
M
Mark Ivanych2015-02-11 12:26:33
Java
Mark Ivanych, 2015-02-11 12:26:33

How to ignore strict sequence of elements in DTD?

Hello, tell me how to make the SAX parser not swear at the incorrect sequence of elements in the file.
I use help.yandex.ru/partnermarket/yml/about-yml.xml
partner.market.yandex.ru/pages/help/shops.dtd
partner.market.yandex.ru/pages/help/YML.xml

<offer id="12342" type="book" bid="17" available="true">
<url>http://magazin.ru/product_page.asp?pid=14345</url>
<price>100</price>
...
</offer>

All you have to do is swap a couple of items.
<offer id="12342" type="book" bid="17" available="true">
<price>100</price>
<url>http://magazin.ru/product_page.asp?pid=14345</url>
...
</offer>

and my parser starts cursing...
The content of element type "offer" must match "(url?,buyurl?,price,wprice?,currencyId,xCategory?,categoryId+,market_category?,picture*,store?,pickup?,delivery?,deliveryIncluded?,local_delivery_cost?,orderingTime?,((typePrefix?,vendor,vendorCode?,model,(provider,tarifplan?)?)|(author?,name,publisher?,series?,year?,ISBN?,volume?,part?,language?,binding?,page_extent?,table_of_contents?)|(author?,name,publisher?,series?,year?,ISBN?,volume?,part?,language?,table_of_contents?,performed_by?,performance_type?,storage?,format?,recording_length?)|(artist?,title,year?,media?,starring?,director?,originalName?,country?)|(worldRegion?,country?,region?,days,dataTour*,name,hotel_stars?,room?,meal?,included,transport,price_min?,price_max?,options?)|(name,place,hall?,hall_part?,date,is_premiere?,is_kids?)|(name,vendor?,vendorCode?)),aliases?,additional*,description?,sales_notes?,promo?,manufacturer_warranty?,country_of_origin?,downloadable?,adult?,age?,barcode*,param*,related_offer*)".

The most interesting thing is that if you check the modified feed in the Yandex.Market, it successfully passes the test. How to be?
Code
try {
     SAXParserFactory factory = SAXParserFactory.newInstance();
     factory.setValidating(true);
     SAXParser parser = factory.newSAXParser();
     XMLReader reader = parser.getXMLReader();
     reader.setContentHandler(this);
     reader.setErrorHandler(this);
     InputSource source = new InputSource("file.xml");
     reader.parse(source);
} finally {}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question