"XML unmarshal error" avec simpleNLG
Bonjour,
J’essaie de faire de la génération de texte en utilisant simpleNLG en passant par le XMLRealiser, mais j'ai toujours l'erreur suivante: "simplenlg.xmlrealiser.XMLRealiserException: XML unmarshal error"
Mon fichier XML ressemble à ça:
<?xml version="1.0" encoding="utf-8"?>
<Document xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" cat="PARAGRAPH" xsi:schemaLocation="http://code.google.com/p/simplenlg/schemas/version1" xmlns="http://code.google.com/p/simplenlg/schemas/version1">
<child xsi:type="SPhraseSpec">
<subj xsi:type = "NPPhraseSpec">
<head cat = "NOUN"> i </head>
</subj>
<vp xsi:type = "VPPhraseSpec" TENSE="PRESENT">
<head cat="VERB"> like </head>
<compl xsi:type = "NPPhraseSpec">
<head cat="NOUN"> skateboard </head>
</compl>
</vp>
</child>
</Document>
Et le bout de code qui plante est le suivant:
public static simplenlg.xmlrealiser.wrapper.NLGSpec getNLGSpec(Reader xmlReader) throws XMLRealiserException {
simplenlg.xmlrealiser.wrapper.NLGSpec wt = null;
try {
JAXBContext jc = JAXBContext.newInstance(simplenlg.xmlrealiser.wrapper.NLGSpec.class);
Unmarshaller u = jc.createUnmarshaller();
Object obj = u.unmarshal(xmlReader); //Ca plante ici...
if (obj instanceof simplenlg.xmlrealiser.wrapper.NLGSpec) {
wt = (simplenlg.xmlrealiser.wrapper.NLGSpec) obj;
}
}
catch (Throwable e) {
throw new XMLRealiserException("XML unmarshal error", e);
}
return wt;
}
La variable "xmlReader" contient le contenu du fichier XML.
Contenue de la pile d'execution:
javax.xml.bind.UnmarshalException: unexpected element (uri:"http://code.google.com/p/simplenlg/schemas/version1", local:"Document"). Expected elements are <{http://simplenlg.googlecode.com/svn/trunk/res/xml}NLGSpec>
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unknown Source)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(Unknown Source)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(Unknown Source)
at simplenlg.xmlrealiser.UnWrapper.getNLGSpec(UnWrapper.java:87)
at simplenlg.xmlrealiser.XMLRealiser.getRequest(XMLRealiser.java:200)
at simplenlg.xmlrealiser.XMLRealiser.main(XMLRealiser.java:106)
at Main_Test_XMLReliser.main(Main_Test_XMLReliser.java:47)
simplenlg.xmlrealiser.XMLRealiserException: XML unmarshal error
Ca fait longtemps que je bloque la dessus donc si quelqu'un a une idée elle est la bienvenue!
Merci d'avance! :-)