You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Guoliang Cao <ca...@ispsoft.com> on 2001/02/01 21:30:28 UTC

Validation problem with the xerces 1.3.0

Hi,

I'm using sax.SAX2Writer  to validate Test.xml  against Test.xsd.

If I use xerces 1.2.3,  it'll pass the validation. If use xerces 1.3.0,
however, it'll output this:

java -cp
\xml-xerces\java\build\xerces.jar;\xml-xerces\java\build\xercesSamples.jar
sax.SAX2Writer -nvs test.xml

test.xml:
<?xml version="1.0" encoding="UTF-8"?>
[Error] test.xml:4:54: General Schema Error: Grammar with uri 2:
http://www.abc.com , can not found.
[Error] test.xml:4:54: Element type "provRequest" must be declared.
<provRequest xsi:schemaLocation="http://www.abc.com Test.xsd">

Can anybody check this please?


Thx,
Guoliang

Re: Validation problem with the xerces 1.3.0

Posted by Elena Litani <hl...@jtcsv.com>.
> I changed the NS, and it passed. However, the output is not good enough:
> java -cp
> Perhaps that's not Xerces's problem, but sax.SAX2Writer's.

Hmm.. you are right.. SAX2Writer behaves strange. If you have time to
dig in and find out what's wrong with it - it would be great!

Bwt, SAXWriter outputs result correctly...


Elena


> 
> Guoliang
> 
> > Hi,
> > Xerces 1.3.0 supports CR Schema specs.
> >
> > Change NS from "http://www.w3.org/1999/XMLSchema-instance" to
> > http://www.w3.org/2000/10/XMLSchema-instance
> >
> > and from "http://www.w3.org/1999/XMLSchema" to
> > "http://www.w3.org/2000/10/XMLSchema"
> >
> > Elena
> >
> > Guoliang Cao wrote:
> > >
> > > Hi,
> > >
> > > I'm using sax.SAX2Writer  to validate Test.xml  against Test.xsd.
> > >
> > > If I use xerces 1.2.3,  it'll pass the validation. If use xerces 1.3.0,
> > > however, it'll output this:
> > >
> > > java -cp
> > > \xml-xerces\java\build\xerces.jar;\xml-xerces\java\build\xercesSamples.jar
> > > sax.SAX2Writer -nvs test.xml
> > >
> > > test.xml:
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > [Error] test.xml:4:54: General Schema Error: Grammar with uri 2:
> > > http://www.abc.com , can not found.
> > > [Error] test.xml:4:54: Element type "provRequest" must be declared.
> > > <provRequest xsi:schemaLocation="http://www.abc.com Test.xsd">
> > >
> > > Can anybody check this please?
> > >
> > > Thx,
> > > Guoliang
> > >
> > >   ------------------------------------------------------------------------
> > > <?xml version="1.0"?>
> > > <schema targetNamespace='http://www.abc.com'
> > >         xmlns='http://www.w3.org/1999/XMLSchema'
> > >         xmlns:req="http://www.abc.com"
> > >         elementFormDefault="qualified">
> > >
> > > <element name="provRequest" type="string"/>
> > >
> > > </schema>
> > >
> > >   ------------------------------------------------------------------------
> > > <?xml version="1.0"?>
> > > <provRequest xmlns='http://www.abc.com'
> > >     xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
> > >     xsi:schemaLocation='http://www.abc.com Test.xsd'>
> > >
> > > </provRequest>
> > >
> > >   ------------------------------------------------------------------------
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org

Re: Validation problem with the xerces 1.3.0

Posted by Guoliang Cao <ca...@ispsoft.com>.
Thanks  Elena,

I changed the NS, and it passed. However, the output is not good enough:
java -cp
\xml-xerces\java\build\xerces.jar;\xml-xerces\java\build\xercesSamples.jar
sax.SAX2Writer -nvs test.xml

<?xml version="1.0" encoding="UTF-8"?>
<provRequest xsi:schemaLocation="http://www.abc.com
file:///c:/cao/upx/xmlschema/provRequestFormats/Test.xsd">

</provRequest>

We should find "xmlns=..."   and   "xmlns:xsi=..."  in the root element, right?
Perhaps that's not Xerces's problem, but sax.SAX2Writer's.

Guoliang

> Hi,
> Xerces 1.3.0 supports CR Schema specs.
>
> Change NS from "http://www.w3.org/1999/XMLSchema-instance" to
> http://www.w3.org/2000/10/XMLSchema-instance
>
> and from "http://www.w3.org/1999/XMLSchema" to
> "http://www.w3.org/2000/10/XMLSchema"
>
> Elena
>
> Guoliang Cao wrote:
> >
> > Hi,
> >
> > I'm using sax.SAX2Writer  to validate Test.xml  against Test.xsd.
> >
> > If I use xerces 1.2.3,  it'll pass the validation. If use xerces 1.3.0,
> > however, it'll output this:
> >
> > java -cp
> > \xml-xerces\java\build\xerces.jar;\xml-xerces\java\build\xercesSamples.jar
> > sax.SAX2Writer -nvs test.xml
> >
> > test.xml:
> > <?xml version="1.0" encoding="UTF-8"?>
> > [Error] test.xml:4:54: General Schema Error: Grammar with uri 2:
> > http://www.abc.com , can not found.
> > [Error] test.xml:4:54: Element type "provRequest" must be declared.
> > <provRequest xsi:schemaLocation="http://www.abc.com Test.xsd">
> >
> > Can anybody check this please?
> >
> > Thx,
> > Guoliang
> >
> >   ------------------------------------------------------------------------
> > <?xml version="1.0"?>
> > <schema targetNamespace='http://www.abc.com'
> >         xmlns='http://www.w3.org/1999/XMLSchema'
> >         xmlns:req="http://www.abc.com"
> >         elementFormDefault="qualified">
> >
> > <element name="provRequest" type="string"/>
> >
> > </schema>
> >
> >   ------------------------------------------------------------------------
> > <?xml version="1.0"?>
> > <provRequest xmlns='http://www.abc.com'
> >     xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
> >     xsi:schemaLocation='http://www.abc.com Test.xsd'>
> >
> > </provRequest>
> >
> >   ------------------------------------------------------------------------
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Make editings conform to XML Schema

Posted by Catharina Ibrahim <c_...@yahoo.com>.
Hi,

I need to make sure any editings to XML document
conform to its corresponding XML Schema, so that any
attempt of editing that doesn't conform the schema
will be rejected right away (not accepted first and
checked later on)

I read in the archives that Xerces can tell a lot
about schema by using GrammarResolver. Jeff Lansing
even kindly provides a code for it. But I'm new to
Java and I can't see how I can use it. I can't even
understand what GrammarResolver is doing.. does
(GrammarResolver instance).getGrammar gives a DOM tree
of schema.. ? (tried to read the API but I find it not
very describing.. )

I use Xerces-J 1.2.3, with DOMParser to parse the
document.

Can anyone plzzzzz help me ? Or if you have any
suggestion of other means to do this ? Would
appreciate examples a lot.. 

thx,
cath


__________________________________________________
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

Re: Validation problem with the xerces 1.3.0

Posted by Elena Litani <hl...@jtcsv.com>.
Hi,
Xerces 1.3.0 supports CR Schema specs.

Change NS from "http://www.w3.org/1999/XMLSchema-instance" to
http://www.w3.org/2000/10/XMLSchema-instance

and from "http://www.w3.org/1999/XMLSchema" to
"http://www.w3.org/2000/10/XMLSchema"

Elena 

Guoliang Cao wrote:
> 
> Hi,
> 
> I'm using sax.SAX2Writer  to validate Test.xml  against Test.xsd.
> 
> If I use xerces 1.2.3,  it'll pass the validation. If use xerces 1.3.0,
> however, it'll output this:
> 
> java -cp
> \xml-xerces\java\build\xerces.jar;\xml-xerces\java\build\xercesSamples.jar
> sax.SAX2Writer -nvs test.xml
> 
> test.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> [Error] test.xml:4:54: General Schema Error: Grammar with uri 2:
> http://www.abc.com , can not found.
> [Error] test.xml:4:54: Element type "provRequest" must be declared.
> <provRequest xsi:schemaLocation="http://www.abc.com Test.xsd">
> 
> Can anybody check this please?
> 
> Thx,
> Guoliang
> 
>   ------------------------------------------------------------------------
> <?xml version="1.0"?>
> <schema targetNamespace='http://www.abc.com'
>         xmlns='http://www.w3.org/1999/XMLSchema'
>         xmlns:req="http://www.abc.com"
>         elementFormDefault="qualified">
> 
> <element name="provRequest" type="string"/>
> 
> </schema>
> 
>   ------------------------------------------------------------------------
> <?xml version="1.0"?>
> <provRequest xmlns='http://www.abc.com'
>     xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
>     xsi:schemaLocation='http://www.abc.com Test.xsd'>
> 
> </provRequest>
> 
>   ------------------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org