|
|
|
Валидация по схеме
|
|||
|---|---|---|---|
|
#18+
С помощью JAXP создаю org.w3c.dom.Document. Задача - его проверить на соответствие схеме. Пытаюсь это сделать с помощью такого кода: -- code -- if (doc != null) { try { // Создание объекта SchemaFactory спосбного работать с WXS схемами. SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); // Загрузка WXS схемы, представленной элементом Schema. Source schemaFile = new StreamSource(getServletContext().getResourceAsStream("WEB-INF/xsd/my.xsd")); Schema schema = factory.newSchema(schemaFile); // Создание объекта Validator, используемого для проверки правильности документа. Validator validator = schema.newValidator(); DOMSource source = new DOMSource(doc); validator.validate(source); System.out.println("validate ok"); } catch (SAXException saxex) { System.out.println(saxex.getMessage()); } catch (IOException ioex) { System.out.println(ioex.getMessage()); } -- end code -- получаю ошибку: cvc-elt.1: Cannot find the declaration of element 'root'. Схема примитивная и валидная. Куда копать? -- Best regards Vasil Yaroshevich http://www.yaroshevich.ru --- Vasil Yaroshevich ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.01.2007, 21:32:59 |
|
||
|
|

start [/forum/topic.php?fid=59&gotonew=1&tid=2146839]: |
0ms |
get settings: |
13ms |
get forum list: |
27ms |
check forum access: |
8ms |
check topic access: |
8ms |
track hit: |
78ms |
get topic data: |
23ms |
get first new msg: |
13ms |
get forum data: |
5ms |
get page messages: |
60ms |
get tp. blocked users: |
3ms |
| others: | 307ms |
| total: | 545ms |

| 0 / 0 |
