Are you using Xerces 1.2.x or 1.3.0?
I'm not sure what the problem is, but this works for me in 1.3.0:
TNS.xml
<?xml version="1.0" encoding="UTF-8"?>
<dv:main
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:dv="http://MyDomain.com/TNS"
xsi:schemaLocation="http://MyDomain.com/TNS TNS.xsd">
<dv:child />
</dv:main>
TNS.xsd
<?xml version="1.0" encoding="UTF-8"?>
<schema
xmlns="http://www.w3.org/2000/10/XMLSchema"
xmlns:dv="http://MyDomain.com/TNS"
targetNamespace="http://MyDomain.com/TNS"
elementFormDefault="qualified">
<element name="main" >
<complexType>
<sequence>
<element name="child" type="dv:child" minOccurs="0"
maxOccurs="unbounded" />
</sequence>
</complexType>
</element>
<complexType name="child" />
</schema>
$ java dom.DOMCount -v TNS.xml
TNS.xml: 415 ms (2 elems, 3 attrs, 4 spaces, 0 chars)
On Mon, Feb 12, 2001 at 05:09:46PM +0100, ibrahim wrote:
> Hi Andy, Neil :)
>
> I tried putting the xsd for targetNamespace and elementFormDefault, but
> DOMParser gives
> General Schema error: Schema in TNS.xsd has a different target namespace from
> the one specified in the instance document: http://MyDomain.com/TNS.
>
> in TNS.xsd
> xsd:targetNamespace="http://MyDomain.com/TNS"
> xsd:elementFormDefault="qualified">
>
> I changed 1999 into 2000/10 but DOMParser also gives General Schema error :
> Grammar with uri 2:http://MyDomain.com/TNS can not found.
>
> in TNS.xsd :
> xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
>
> in TNS.xml:
> xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
>
> btw, better ask again to make sure. This namespace (http://MyDomain.com/TNS in
> this case) does not need to be a truly existing url right... ?
>
> thx :)
> cath
>
> Andrew Newton wrote:
>
> > Cath,
> >
> > Just a guess, but try "xsd:targetNamespace" and
> > "xsd:elementFormDefault" in your schema.
> >
> > -andy
> >
> > On Mon, Feb 12, 2001 at 03:47:17PM +0100, ibrahim wrote:
> > > Hi,
> > >
> > > I'm trying to use namespace for my XML document here. I tried putting in
> > > the example of TNS documents plus binding and elementFormDefault to be
> > > 'qualified' :
> > >
> > > TNS.xml:
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <dv:main
> > > xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
> > > xmlns:dv="http://MyDomain.com/TNS"
> > > xsi:schemaLocation="http://MyDomain.com/TNS TNS.xsd">
> > > <dv:child />
> > > </dv:main>
> > >
> > > TNS.xsd:
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <xsd:schema
> > > xmlns:xsd="http://www.w3.org/1999/XMLSchema"
> > > xmlns="http://MyDomain.com/TNS"
> > > targetNamespace="http://MyDomain.com/TNS"
> > > elementFormDefault="qualified">
> > >
> > > <xsd:element name="main" >
> > > <xsd:complexType content="elementOnly">
> > > <xsd:element name="child" type="child" minOccurs="0"
> > > maxOccurs="unbounded" />
> > > </xsd:complexType>
> > > </xsd:element>
> > >
> > > <xsd:complexType name="child" content="empty" />
> > >
> > > </xsd:schema>
> > >
> > > But the parser gives erros saying that "dv:main" and "dv:child" must be
> > > declared. What's wrong?
> > >
> > > thanks a lot for your help,
> > > cath
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> > --
> > Andrew Newton
> > [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
Andrew Newton
Verisign Applied Research
[EMAIL PROTECTED]