You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by EJ Ciramella <ej...@upromise.com> on 2006/09/01 18:26:27 UTC

xml validation woes

I'm having a bit of trouble validating a very simple xml file (for
testing purposes).
 
Can anyone shed some light on this for me please?
 
Here is my build script:
 
<target name="build">
  <xmlvalidate failonerror="true" lenient="false" warn="true"
file="test.xml" classname="org.apache.xerces.parsers.SAXParser"> 
      <attribute name="http://xml.org/sax/features/validation"
                 value="true"/>
      <attribute name="http://apache.org/xml/features/validation/schema"
                 value="true"/>
  </xmlvalidate>
  <xslt basedir="." includes="test.xml" destdir="." extension=".html"
style="test.xsl"/>
</target>
 
Here is my xml file:
 
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<tester xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="file://e:/work/docs/engineering/builds/te
st.xsd">
    <test>Hello world</test>
</tester>
 
Here is my xsd file:
 
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:element name="tester">
       <xs:complexType>
           <xs:sequence>
               <xs:element name="test" type="xs:string"/>
           </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
 
No matter what I do, I wind up with the following error:
 
cvc-elt.1: Cannot find the declaration of element 'tester'.
 
 

Re: xml validation woes

Posted by Steve Loughran <st...@apache.org>.
EJ Ciramella wrote:
> I'm having a bit of trouble validating a very simple xml file (for
> testing purposes).
>  
> Can anyone shed some light on this for me please?
>  
> Here is my build script:
>  
> <target name="build">
>   <xmlvalidate failonerror="true" lenient="false" warn="true"
> file="test.xml" classname="org.apache.xerces.parsers.SAXParser"> 
>       <attribute name="http://xml.org/sax/features/validation"
>                  value="true"/>
>       <attribute name="http://apache.org/xml/features/validation/schema"
>                  value="true"/>
>   </xmlvalidate>
>   <xslt basedir="." includes="test.xml" destdir="." extension=".html"
> style="test.xsl"/>
> </target>
>  
> Here is my xml file:
>  
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <?xml-stylesheet type="text/xsl" href="test.xsl"?>
> <tester xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="file://e:/work/docs/engineering/builds/te
> st.xsd">
>     <test>Hello world</test>
> </tester>
>  
> Here is my xsd file:
>  
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>    <xs:element name="tester">
>        <xs:complexType>
>            <xs:sequence>
>                <xs:element name="test" type="xs:string"/>
>            </xs:sequence>
>         </xs:complexType>
>     </xs:element>
> </xs:schema>
>  
> No matter what I do, I wind up with the following error:
>  

1. Ant1.7's <schemavalidate> adds schema awareness to xmlvalidate. use 
it if you can -the beta is out now

> cvc-elt.1: Cannot find the declaration of element 'tester'.
>  

Its a xerces error, probably that it hasnt picked up the no-namespace 
schema location.

If you can't upgrade to ant1.7 and its new task, copy it and set the no 
namespace location based on the relevant xerces property:

http://xerces.apache.org/xerces-j/properties.html

> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: xml validation woes

Posted by Dominique Devienne <dd...@gmail.com>.
> xsi:noNamespaceSchemaLocation="file://e:/work/docs/...

Try with file:/e:/work/docs and file:///e:/work/docs.

Depends on the JDK which one works I think ;-) --DD

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org