Hi
This is a first for me ! i am a beginner in Java & am aiming to develop a servlet which will process the attributes & values of the nodes from an xml files url-encoded into a http POST request;
So far i am stuck when accessing the attributes of the nodes from the DOM Document that i had used to represent the xml file ...
Please find hereunder in red the bugging lines causing the error message "The type of expression must be an array type but it is resolved to NodeList":
public void acceptRepresentation(Representation entity) throws ResourceException {
log.info("Traitement d'un POST sur la ressource CreateSoundFilefromSSML");
// Récupération des paramètres du formulaire : le flux XML représentant
// une animation en découlera
Form form = new Form(entity);
String ssmlStr = form.getFirstValue("SSML");
String apiSigStr = form.getFirstValue("apisig");
String decodedSsmlString = URLDecoder.decode(ssmlStr, "UTF-8");
DocumentBuilderFactory ssmlFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder ssmlBuilder = null;
try{
ssmlBuilder = ssmlFactory.newDocumentBuilder();
Document ssmlDocument= ssmlBuilder.newDocument();
String voiceNameStr= ssmlDocument.getElementsByTagName("prosody")[0].childNodes[0].getAttribute("name");
String texttosyntStr= ssmlDocument.getElementsByTagName("prosody")[0].childNodes[0].nodeValue;
String audiosrcStr= ssmlDocument.getElementsByTagName("audio")[0].getAttribute("src");
String prosodyrateStr= ssmlDocument.getElementsByTagName("prosody")[0].getAttribute("rate");
String langStr= ssmlDocument.getElementsByTagName("speak")[0].getAttribute("xml:lang");
}catch(ParserConfigurationException pce) {
pce.printStackTrace();
}catch(SAXException se) {
se.printStackTrace();
}catch(IOException ioe) {
ioe.printStackTrace();
}
}
I know it must have something to do with the DOM Document declaration & methods calls but you could someone please help me to pinpoint what' wrong ?
Hoping it's not too much to ask ...
Thankx in advance !
This is a first for me ! i am a beginner in Java & am aiming to develop a servlet which will process the attributes & values of the nodes from an xml files url-encoded into a http POST request;
So far i am stuck when accessing the attributes of the nodes from the DOM Document that i had used to represent the xml file ...
Please find hereunder in red the bugging lines causing the error message "The type of expression must be an array type but it is resolved to NodeList":
public void acceptRepresentation(Representation entity) throws ResourceException {
log.info("Traitement d'un POST sur la ressource CreateSoundFilefromSSML");
// Récupération des paramètres du formulaire : le flux XML représentant
// une animation en découlera
Form form = new Form(entity);
String ssmlStr = form.getFirstValue("SSML");
String apiSigStr = form.getFirstValue("apisig");
String decodedSsmlString = URLDecoder.decode(ssmlStr, "UTF-8");
DocumentBuilderFactory ssmlFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder ssmlBuilder = null;
try{
ssmlBuilder = ssmlFactory.newDocumentBuilder();
Document ssmlDocument= ssmlBuilder.newDocument();
String voiceNameStr= ssmlDocument.getElementsByTagName("prosody")[0].childNodes[0].getAttribute("name");
String texttosyntStr= ssmlDocument.getElementsByTagName("prosody")[0].childNodes[0].nodeValue;
String audiosrcStr= ssmlDocument.getElementsByTagName("audio")[0].getAttribute("src");
String prosodyrateStr= ssmlDocument.getElementsByTagName("prosody")[0].getAttribute("rate");
String langStr= ssmlDocument.getElementsByTagName("speak")[0].getAttribute("xml:lang");
}catch(ParserConfigurationException pce) {
pce.printStackTrace();
}catch(SAXException se) {
se.printStackTrace();
}catch(IOException ioe) {
ioe.printStackTrace();
}
}
I know it must have something to do with the DOM Document declaration & methods calls but you could someone please help me to pinpoint what' wrong ?
Hoping it's not too much to ask ...
Thankx in advance !