Bonjour,

je n'arrive pas comprendre certaines propriétés de Xerces:
http://xml.org/sax/features/namespaces
http://xml.org/sax/features/namespace-prefixes

J'ai un schéma xsd et une instance xml :

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
<?xml version="1.0" encoding="UTF-8"?>
 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.example.org/xml-xsd-ns-prefixes" 
  xmlns="http://www.example.org/xml-xsd-ns-prefixes"
  elementFormDefault="qualified">
 
  <xsd:element name="message" type="xsd:string"/>
  <xsd:element name="messages">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="message" maxOccurs="3"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>  
 
</xsd:schema>

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
<my:messages xmlns:my="http://www.example.org/xml-xsd-ns-prefixes"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.example.org/xml-xsd-ns-prefixes 
    xml-xsd-ns-prefixes.xsd">
  <my:message>Hello From XSLT</my:message>
  <my:message>From input: Hi</my:message>
  <my:message>ANT AND XSLT ROCK</my:message>
</my:messages>
Pour valider mon xml à l'aide mon schéma, j'ai défini les propriétés :
http://xml.org/sax/features/validation : true
http://apache.org/xml/features/validation/schema : true

Puis, j'ai fais deux petits tests :
http://xml.org/sax/features/namespaces : true
http://xml.org/sax/features/namespace-prefixes : false
La validation passe.

L'autre test :
http://xml.org/sax/features/namespaces : false
http://xml.org/sax/features/namespace-prefixes : true
Xerves me retourne : cvc-elt.1: Cannot find the declaration of element 'my:messages'.

Et je ne comprends pas pourquoi !!! Alors si vous avez une idée ...