Bonjour;
je doit récupérer des données depuis un fichier XML. Le problème est que dans une balise il y a l'attribut xsi:schemaLocation. Mon XML est le suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
<catalogueItem creationDateTime="2006-01-10T12:00:01.000-05:00" documentStatus="ORIGINAL" xsi:schemaLocation="urn:ean.ucc:2 ../Schemas/CatalogueProxy.xsd">
<catalogueReference>
		<Reference>2</Reference>
</catalogueReference>
</catalogueItem>
Eclipse me retourne l'erreur suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
[Fatal Error] :1:184: The prefix "xsi" for attribute "xsi:schemaLocation" associated with an element type "catalogueItem" is not bound.
org.xml.sax.SAXParseException: The prefix "xsi" for attribute "xsi:schemaLocation" associated with an element type "catalogueItem" is not bound.
	at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
	at com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:291)
	at Sessai.evaluerSAX(Sessai.java:42)
	at Sessai.main(Sessai.java:69)
--------------- linked to ------------------
javax.xml.xpath.XPathExpressionException
	at com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:294)
	at Sessai.evaluerSAX(Sessai.java:42)
	at Sessai.main(Sessai.java:69)
Caused by: org.xml.sax.SAXParseException: The prefix "xsi" for attribute "xsi:schemaLocation" associated with an element type "catalogueItem" is not bound.
	at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
	at com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:291)
	... 2 more
voici ma classe java:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
39
40
41
42
43
44
45
46
 
import org.w3c.dom.*; 
import org.xml.sax.*;
import javax.xml.*; 
import javax.xml.parsers.*; 
import javax.xml.transform.*; 
import javax.xml.transform.dom.*; 
import javax.xml.transform.sax.*; 
import javax.xml.xpath.*; 
import javax.xml.namespace.*; 
import java.io.*;
 
public class ssessai{
 
 
	public static String evaluerSAX(File fichier, String expression, QName retour) throws FileNotFoundException, XPathExpressionException{
 
			//création de la source
			InputSource source = new InputSource(new FileInputStream(fichier));
 
			//création du XPath 
			XPathFactory fabrique = XPathFactory.newInstance();
			XPath xpath = fabrique.newXPath();
 
			//évaluation de l'expression XPath
			XPathExpression exp = xpath.compile(expression);
			Object resultat = exp.evaluate(source,retour);
 
 
			String value = resultat.toString();
 
			return (value);
 
 
	}
	public static void main(String[] args){
 
		try{
			File xml = new File("templates/CatalogueItem.xml");
			String ddd = evaluerSAX(xml, "/catalogueItem/catalogueReference/Reference", XPathConstants.STRING);
			System.out.println(ddd);
		}catch(Exception e){
			e.printStackTrace();	
		}
	}	
}
Quand j'élimine j'arrive à récupérer la référence.Mais j'ai besoin de cet attribut.
Voila si vous pouvez m'aider.
Merci.