|
|
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
Например меня есть test.xml и scheme.xsd, как проверить, что файл действительно соответсвует указанной схеме. Я делаю Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. Как указать где лежит схема? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.03.2005, 13:53 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
тынц from J2EE Tutorial. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.03.2005, 13:59 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
спасибо ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.03.2005, 14:29 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
что я делаю не так? Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 24.03.2005, 18:42 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
тебе нужно подключить к своему парсеру обработчик ошибок, а то их попросту не видно, для DOM делается так . Код: plaintext 1. 2. 3. обработчик ошибок Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 24.03.2005, 18:52 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
спасибо, с этим разобрался... Теперь у меня немного другая задача У меня есть файл file.xml в котором есть информация о схеме и есть 2 схемы schema1.xsd и schema2.xsd - как указать парсеру только их местоположение Т.е. если я использую saxParser.setProperty(JAXP_SCHEMA_SOURCE, new File(schemaSource)); то только на соответсвие этой схеме и будет проверяться документе, мне же нужно использовать схему документа, но где именно лежит сама схема парсер не знает! ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.03.2005, 13:42 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
Сказать по правде, не хрена я не понял вопрося :) Можешь еще раз по подробнее? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.03.2005, 13:46 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
как указать парсеру где какая схема лежит (пути к схемам)? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.03.2005, 13:53 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
funikovyuriкак указать парсеру где какая схема лежит (пути к схемам)? может это: Declaring the Schemas in the XML Data Set To declare the schemas to use for the preceding example in the data set, the XML code would look something like this: <documentRoot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="employeeDatabase.xsd" xsi:schemaLocation= "http://www.irs.gov/ fullpath/w2TaxForm.xsd http://www.ourcompany.com/ relpath/hiringForm.xsd" xmlns:tax="http://www.irs.gov/" xmlns:hiring="http://www.ourcompany.com/" > ... The noNamespaceSchemaLocation declaration is something you've seen before, as are the last two entries, which define the namespace prefixes tax and hiring. What's new is the entry in the middle, which defines the locations of the schemas to use for each namespace referenced in the document. The xsi:schemaLocation declaration consists of entry pairs, where the first entry in each pair is a fully qualified URI that specifies the namespace, and the second entry contains a full path or a relative path to the schema definition. (In general, fully qualified paths are recommended. In that way, only one copy of the schema will tend to exist.) Note that you cannot use the namespace prefixes when defining the schema locations. The xsi:schemaLocation declaration understands only namespace names and not prefixes. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.03.2005, 14:15 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
в том та и дело, в моих документах есть имя схемы, но не ее location! Я знаю где эти схемы лежат. Как мне без изменения документов указать парсеру где брать для них схемы? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.03.2005, 14:50 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
funikovyuriв том та и дело, в моих документах есть имя схемы, но не ее location! Я знаю где эти схемы лежат. Как мне без изменения документов указать парсеру где брать для них схемы? А никак. У меня была такая же задача, я сделал такой файл: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. Вобщем там мапинг: namespace докмунта и каждому намеспейсу соответсвует своя схема. Ну а реализовать логику, это уже дело техники. Я через JAXP все делал. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.03.2005, 14:58 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
не понял, а что с этим файлом (<schemaMappings>) дальше делать? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.03.2005, 15:58 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
funikovyuriне понял, а что с этим файлом (<schemaMappings>) дальше делать? Парсить его надо, это как обычный файл properties. Я заганял все в Hashmap, globalSchemaLocation это как key, LocalSchemalocation как value. ну и далее, получал namespace (key к Hashmap) xml дукумента и искал в hashmap значение, которое и является путем к схеме. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.03.2005, 16:27 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
Я и так знаю где лежат схемы! Как это парсеру указать? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.03.2005, 16:40 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
funikovyuriЯ и так знаю где лежат схемы! Как это парсеру указать? Ну ё моё.... как я понял, у тебя проблема в том, что в исходных XML нету полнлго пути к схеме. Так вот, все пути прописываются в файл (в любом формате, какой тебе удобнее), затем, используя определенный ключ ( в моем случае это namespase, в твоем как я понял это имя схемы) ты из этого файла получаешь полный путь к схеме и указывешь его парсеру вот так -> saxParser.setProperty(JAXP_SCHEMA_SOURCE, new File(schemaSource-здесь путь, Генерируется динамически!)). зы это все верно если я правильно понял твою проблему :) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.03.2005, 16:57 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
Я нашел правильное решение. Называется XML Catalog ! ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 28.03.2005, 10:58 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
funikovyuriЯ нашел правильное решение. Называется XML Catalog ! Это и есть то самое, что я тебе объяснить пытался, только в своё время я сам подобное написал. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 28.03.2005, 11:31 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
Это не тоже самое, далеко не тоже самое :) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 28.03.2005, 11:37 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
funikovyuriЭто не тоже самое, далеко не тоже самое :) Ну разве это не то же самое, что я тебе объяснял ?:) автор Example 2: W3C XML Schema Validation In the same way that an XML document may associate itself with a DTD via the DOCTYPE declaration, an XML document may associate itself with a W3C XML Schema using a schema location hint. This example looks at how to validate a document against a schema specified in this way. A schema location hint is an xsi:schemaLocation attribute on an element -- typically the root -- whose value is a list of namespace URIs and URIs for the schemas to validate elements in those namespaces. Alternatively, if the elements are not in a namespace, a schema location hint is an xsi:noNamespaceSchemaLocation attribute whose value is a URI for the schema. The xsi prefix is bound to the http://www.w3.org/2001/XMLSchema-instance namespace URI. For example, here is an XML instance document that describes a recipe, and declares itself to be valid with respect to the schema located at http://tiling.org/xmlcatalogs/schemas/recipe.xsd in the http://tiling.org/xmlcatalogs/namespaces/recipe namespace: <?xml version="1.0" encoding="UTF-8"?> <recipe xmlns="http://tiling.org/xmlcatalogs/namespaces/recipe" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://tiling.org/xmlcatalogs/namespaces/recipe http://tiling.org/xmlcatalogs/schemas/recipe.xsd"> <author>Elizabeth David</author> <name>Omelette</name> <ingredient>3-4 eggs</ingredient> <ingredient>1/2 oz. butter</ingredient> <ingredient>Salt and pepper</ingredient> <method>Beat the eggs...</method> </recipe> Although not explicitly marked as a system identifier we can use a catalog with a system element to associate the schema with a local copy. <?xml version="1.0" encoding="UTF-8"?> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> <system systemId="http://tiling.org/xmlcatalogs/schemas/recipe.xsd" uri="catalog/recipe.xsd"/> </catalog> ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 28.03.2005, 12:13 |
|
||
|
xml scheme validation используя xerces
|
|||
|---|---|---|---|
|
#18+
Ты предложил подставлять путь к схеме с помощью Код: plaintext 1. Напротив в ссылке которую привел я во время парсинга используется CatalogResolver, который заменяет ссылки на схему в документе на локальную. Общего только map-подобная структура хранения глобальных/локальных путей к схемам - это да - только используется эта информация по-разному! ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 28.03.2005, 16:24 |
|
||
|
|

start [/forum/topic.php?fid=59&msg=32979490&tid=2152712]: |
0ms |
get settings: |
9ms |
get forum list: |
16ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
50ms |
get topic data: |
8ms |
get forum data: |
2ms |
get page messages: |
49ms |
get tp. blocked users: |
1ms |
| others: | 243ms |
| total: | 384ms |

| 0 / 0 |
