Bonjour,
Je doit vérifier que des fichiers vxml sont bien formés. Pour cela j'ai récupéré le xsd du w3c. pourtant j'ai une erreur indiquant que le schémat est mal formé. Si quelqu'un à une idée car je sèche là
Pour cela j'utilise le bout de code suivant
L’erreur générée est la suivanteCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 String path = new File(".").getCanonicalPath() + "\\src\\test\\"; SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); File schemaLocation = new File(path + "vxml.xsd"); Schema schema = factory.newSchema(schemaLocation); Validator validator = schema.newValidator(); DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(true); // never forget this DocumentBuilder builder = domFactory.newDocumentBuilder(); Document doc = builder.parse(new File(path + "test.vxml")); DOMSource source = new DOMSource(doc); DOMResult result = new DOMResult(); try { validator.validate(source, result); Document augmented = (Document) result.getNode(); // do whatever you need to do with the augmented document... } catch (SAXException ex) { System.out.println("test.vxml is not valid because "); System.out.println(ex.getMessage()); }
le fichier test.vxmlCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'EventHandler.attribs' to a(n) 'attribute group' component. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getGlobalDecl(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDAttributeGroupTraverser.traverseLocal(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDAbstractTraverser.traverseAttrsAndAttrGrps(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDComplexTypeTraverser.processComplexContent(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDComplexTypeTraverser.traverseComplexTypeDecl(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDComplexTypeTraverser.traverseGlobal(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.traverseSchemas(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source) at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source) at javax.xml.validation.SchemaFactory.newSchema(Unknown Source) at javax.xml.validation.SchemaFactory.newSchema(Unknown Source) at test.Test.validationBis(Test.java:85) at test.Test.main(Test.java:36)
le fichier vxml.xsd à télécharger http://www.w3.org/TR/voicexml20/vxml.xsdCode:
1
2
3
4
5
6
7
8
9
10
11
12
13 <?xml version="1.0" encoding="UTF-8"?> <vxml xmlns="http://www.w3.org/2001/vxml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/vxml http://www.w3.org/TR/voicexml20/vxml.xsd" version="2.0"> <form> <field name="drink"> <prompt>Would you like coffee, tea, milk, or nothing?</prompt> <grammar src="drink.grxml" type="application/srgs+xml"/> </field> <block> <submit next="http://www.drink.example.com/drink2.asp"/> </block> </form> </vxml>