[jdom-interest] Jdom attribut not declared ... but can use

Per Norrman per.norrman at austers.se
Fri Mar 4 15:33:16 PST 2005


Hi,

XMLSpy thinks that the XML is valid. Wether it is valid or not,
is a xerces vs W3C Schema issue, since JDOM delegates schema
validation to the XML parser.

/pmn



Christian Avril skrev:
> Does somebody know why I don't see any error with JDOM ?
> ( See rules.xml and rules.xsd on bottom )
> Because there are 4 errors :  The 'name' attribute is not declared in 
> rules.xsd.... <filtre name = "filter1">
> It's an error because the element <filtre> is not declared as a complex 
> element  .
> With another website online validator , I have found this 4 errors .
> But with JDOM , no error, and I can even obtain the name attribut ....( 
> which is not decalred....)
> Is it a bug or not ?
> ...
>     log.info("  Filtre Name : "    +  
> onefilter.getAttribute("name").getValue() );
>     gives -> Filtre Name : filter1 ...etc
> 
> """"""""""""""""""""""""""""""""""""""""""""""
> With another validator : 4 errors found
> """""""""""""""""""""""""""""""""""""""""""""""
> *Validation error: *
> 
> <?xml version="1.0"?> <habilitations xmlns:xsi = 
> "http://www.w3.org/2001/XMLSchema-instance" 
> xsi:noNamespaceSchemaLocation = "rules.xsd"> <population name = "pop1"> 
> Error at (6,13): The 'name' attribute is not declared. An error occurred 
> at , (6, 13).<filtre name = 
> "filter1">ou=3106,ou=structures,ou=centrale,ou=mefi,o=gouv,c=fr</filtre> 
> Error at (7,13): The 'name' attribute is not declared. An error occurred 
> at , (7, 13).<filtre name = "filter2">fonction=PROGRAMMEUR</filtre> 
> </population> <population name = "pop2"> Error at (11,13): The 'name' 
> attribute is not declared. An error occurred at , (11, 13).<filtre name 
> = "filter1">ou=structures,ou=centrale,ou=mefi,o=gouv,c=fr</filtre> Error 
> at (12,13): The 'name' attribute is not declared. An error occurred at , 
> (12, 13).<filtre name = "filter2">fonction=PUPITREUR</filtre> 
> </population> <population name = "pop3"> Error at (16,13): The 'name' 
> attribute is not declared. An error occurred at , (16, 13).<filtre name 
> = "filter1">ou=structures,ou=centrale,ou=mefi,o=gouv,c=fr</filtre> Error 
> at (17,13): The 'name' attribute is not declared. An error occurred at , 
> (17, 13).<filtre name = "filter2">ousigle=MCF/DIVERS</filtre> 
> </population> </habilitations>
> 
>  
> """""""""""""""""""""""""""""""""""
> But with JDOM no error found
> """""""""""""""""""""""""""""""""""
>         String fichierxml = args[0];
>         SAXBuilder builder = new 
> SAXBuilder("org.apache.xerces.parsers.SAXParser", true);
>         
> builder.setFeature("http://apache.org/xml/features/validation/schema", 
> true);
>         try {
>                 Document doc = builder.build(fichierxml);
> .../...
> -------------------------------------------------------------------------------
> See my files:
>  
> rules.xml
> -------------------------------------------------------------------------------
> <?xml version="1.0"?>
>  <habilitations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>               xsi:noNamespaceSchemaLocation="rules.xsd">
>   
>    <population name="pop1">
>     <filtre 
> name="filter1">ou=3106,ou=structures,ou=centrale,ou=mefi,o=gouv,c=fr</filtre>
>     <filtre name="filter2">fonction=PROGRAMMEUR</filtre>
>    </population>
>   
>    <population name="pop2">
>     <filtre 
> name="filter1">ou=structures,ou=centrale,ou=mefi,o=gouv,c=fr</filtre>
>     <filtre name="filter2">fonction=PUPITREUR</filtre>
>    </population>
>     
>    <population name="pop3">
>     <filtre 
> name="filter1">ou=structures,ou=centrale,ou=mefi,o=gouv,c=fr</filtre>
>     <filtre name="filter2">ousigle=MCF/DIVERS</filtre>
>    </population> 
>  
>  </habilitations>
> ------------------------------------------------------------------------------------------
>  
> rules.xsd
> ------------------------------------------------------------------------------------------
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>  
>  <xsd:element name="habilitations">
>       <xsd:complexType>
>          <xsd:sequence minOccurs="0" maxOccurs="unbounded">
>             <xsd:element name="population" minOccurs="0" 
> maxOccurs="unbounded">
>                  <xsd:complexType>
>                       <xsd:sequence minOccurs="0" maxOccurs="unbounded">
>                            <xsd:element   name="filtre" minOccurs="1" 
> maxOccurs="unbounded"/>
>                       </xsd:sequence>
>                       <xsd:attribute name="name" type="xsd:string" 
> use="required"/>
>                  </xsd:complexType>
>             </xsd:element> 
>         </xsd:sequence>
>      </xsd:complexType>    
>    </xsd:element>
> </xsd:schema>
> -----------------------------------------------------------------------------------------------
>  
>  
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com



More information about the jdom-interest mailing list