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

Christian Avril christian.avril at dpma.finances.gouv.fr
Mon Mar 7 06:37:15 PST 2005


Hi, 

Yes, you are right. JDOM delegates schema validation.
Sorry for this error, and thank you for this information.
Then, I was looking at my xerces.jar ,  but it's the same as online's 
xerces.jar 937 Ko    2004-Feb-04 )

But if it is a xerces's problem, what should I do ? with xerces and Apache I mean.

About my file, rules.xsd, I have found another schema declaration : 
And JDOM, sorry, xerces works with it . ( and also another XSD Schema Validation )
But maybe we can make shorter ?
---------------------------------------------------------------------------------------
<xsd:element name = "filtre">
        <xsd:complexType>
          <xsd:simpleContent>
           <xsd:extension base = "xsd:string">
             <xsd:attribute name = "name" use = "required"/>
           </xsd:extension>
          </xsd:simpleContent>
        </xsd:complexType>
      </xsd:element>    
-----------------------------------------------------------------------------------------
better than 
------
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
       <xsd:element   name="filtre" minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
-------------------------------------------------------------------

Best regards

Chris
  ----- Original Message ----- 
  From: Per Norrman 
  To: Christian Avril 
  Cc: jdom-interest at jdom.org 
  Sent: Saturday, March 05, 2005 12:33 AM
  Subject: Re: [jdom-interest] Jdom attribut not declared ... but can use


  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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20050307/40563a82/attachment.htm


More information about the jdom-interest mailing list