Michael,

Thanks. Based on this I forced the use of the correct impl by calling
DocumentBuilderImpl and also XMLSchemaFactory. And the problem did not go
away. So while there may be classloader issues that caused me to use the
wrong parser, the right parser also rejects this file, but only inside a
webapp.

In case it rings any bells, the validation error is:

cvc-complex-type.3.2.2: Attribute 'lang' is not allowed to appear in element
'regexp'.

The schema is so embarassingly simple that I'll include it here. I can't
figure out how it would ever reject a lang attribute on a 'regexp', let
alone only inside of the webapp.

<xs:schema targetNamespace="" elementFormDefault="unqualified"
    xmlns:xs="http://www.w3.org/2001/XMLSchema";
attributeFormDefault="unqualified">

    <xs:element name="regexpset">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="define" minOccurs='0'
maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:simpleContent>
                            <xs:extension base="xs:string">
                                <xs:attribute name="name" use="required" />
                                <xs:attribute name="lang" use="optional" />
                            </xs:extension>
                        </xs:simpleContent>
                    </xs:complexType>
                </xs:element>
                <xs:element name="regexp" minOccurs='0'
maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:simpleContent>
                            <xs:extension base="xs:string">
                                <xs:attribute name="type" use="required" />
                                <xs:attribute name="lang" use="optional" />
                            </xs:extension>
                        </xs:simpleContent>
                    </xs:complexType>

                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>







On Thu, Oct 29, 2009 at 1:41 PM, Michael Glavassevich
<mrgla...@ca.ibm.com>wrote:

> Hi Benson,
>
> DocumentBuilderFactory and the other JAXP factories use the current
> thread's context ClassLoader by default for locating the implementation. If
> for whatever reason the implementation you wanted loaded isn't visible to
> this ClassLoader you'll get a different implementation, most likely the
> default one in the JDK. Couldn't tell you how this is occurring in your
> environment. I've never used Tomcat or Maven.
>
> Thanks.
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrgla...@ca.ibm.com
> E-mail: mrgla...@apache.org
>
> Benson Margulies <bimargul...@gmail.com> wrote on 10/29/2009 12:35:42 PM:
>
>
> > I have some code that uses DocumentBuilderFactory etc. (JAXP) to
> > parse a document with W3C schema validation.
> >
> > My unit tests work fine with Xerces in the classpath.
> >
> > When the business is all packaged into a webapp and deployed in
> > tomcat (via mvn tomcat:run), the validation fails with bogus error,
> > and the backtrace shows that I'm using whatever nasty version of
> > JAXP is sitting in the JVM. Short of calling
> > DocumentBuilderFactoryImpl, can anyone tell me what I'm doing wrong?
> > The xerces Jar is in the WAR file in the right place.
>
>

Reply via email to