Bonjour,
J'ai un problème avec l'utilisation des namespaces de JDom. En fait, le résultat recherché est le suivant :
mais j'e n'arrive pas à générer le 3ème attribut xsi:schemaLocation.
Code : Sélectionner tout - Visualiser dans une fenêtre à part <root xmlns="http://www.example.org/MySchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/MySchema mySchema.xsd">
Voici le bout de code que j'ai :
et voici le résultat obtenu :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 Namespace xmlns = Namespace.getNamespace("http://www.example.org/MySchema"); root.setNamespace(xmlns); Namespace xmlnsXsi = Namespace.getNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance"); root.addNamespaceDeclaration(xmlnsXsi); Namespace xsiSchemaLocation = Namespace.getNamespace("schemaLocation", "http://www.example.org/MySchema MLDXMLSchema.v2_2.xsd");
Si vous avez une solution pour remplacer le préfix xmlns par xsi pour le dernier attribut, je suis preneur...
Code : Sélectionner tout - Visualiser dans une fenêtre à part <root xmlns="http://www.example.org/MySchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:schemaLocation="http://www.example.org/MySchema mySchema.xsd">
Merci d'avance...
Romain
Partager