XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] Undeclared prefix error with Xerces Java on Mac only

George Cristian Bina <george@oxygenxml.com> wrote on 03/10/2009 08:55:12 PM:

> Hi Michael,
>
> There is one problem I could spot on your file, the schemaLocation
> should contain one or more pairs of the form
> namespace location
> and you specify only a location. You should correct that as below:
>
> xsi:schemaLocation="http://openscoreformat.sourceforge.net/osf/metadata
> http://www.recordare.com/xsd/metadata.xsd"
>
> The next thing you should do after you update the schemaLocation as
> above (if you still get the error) is to check if you load Xerces or
> another schema parser, print the validator class name and see if that is
> what you expect or not.


And I think that is the most likely problem. I recall that the factory loading code for SchemaFactory (and XPathFactory too) in Java 5 was at one time and possibly still is busted [1]. You end up getting the JDK SchemaFactory instead of the one from Xerces. The code donated to Apache had this bug and we fixed it before it (i.e. the JAXP 1.3 version of xml-apis.jar) was released with Xerces-J 2.7.0 (the first Xerces release to support SchemaFactory). I'd suggest you include the Apache xml-apis.jar in the JDK endorsed directory so that the correct SchemaFactory implementation gets loaded.

> Further you can see if you load that class from
> the library you expect it to be loaded from or from some other
> (eventually older) library. For that you can load the .class file as
> resource and see where that comes from. A quick search shows also some
> code that does that:
> http://www.techtalkz.com/414239-post6.html
>
> Hope that helps,
> George
> --
> George Cristian Bina
> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
> http://www.oxygenxml.com
>
>
> Michael Good wrote:
> > I am running into a platform-specific XSD validation issue that has me
> > stumped. Hopefully this group has some advice on things to check.
> >
> > I'm working on a program that validates Open Score Format files
> > (http://openscoreformat.sourceforge.net/). Open Score Format is an
> > extension of MusicXML 2.0 that, among other things, adds a standard
> > metadata file format. It is the validation of this metadata file that
> > causes the problem.
> >
> > The program uses the Xerces Java 2.9.1 parser. On a Windows system
> > running Java 6, all validates fine. On Mac systems running Java 5,
> > metadata files generate the validation error:
> >
> >   UndeclaredPrefix: Cannot resolve 'dcterms:W3CDTF' as a QName: the
> > prefix 'dcterms' is not declared.
> >
> > Here is a sample file that causes the problem:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <osfmeta:osf-package-metadata-baseline
> > xmlns:osfmeta="http://openscoreformat.sourceforge.net/osf/metadata"
> > xmlns:dc="http://purl.org/dc/elements/1.1/"
> > xmlns:dcterms="http://purl.org/dc/terms/"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:schemaLocation="http://www.recordare.com/xsd/metadata.xsd">
> >    <dc:title>1. Im wunderschönen Monat Mai</dc:title>
> >    <dc:creator>Robert Schumann</dc:creator>
> >    <dc:description>DICHTERLIEBE, Op. 48</dc:description>
> >    <dc:publisher/>
> >    <dcterms:created xsi:type="dcterms:W3CDTF">2009-03-10</dcterms:created>
> >    <dcterms:issued xsi:type="dcterms:W3CDTF">2009-03-10</dcterms:issued>
> >    <dcterms:modified xsi:type="dcterms:W3CDTF">2009-03-10</dcterms:modified>
> >    <dcterms:dateCopyrighted
> > xsi:type="dcterms:W3CDTF">2009</dcterms:dateCopyrighted>
> >    <dc:type xsi:type="dcterms:DCMIType">InteractiveResource</dc:type>
> >    <dcterms:medium
> > xsi:type="dcterms:IMT">application/vnd.yamaha.openscoreformat.
> osfpvg+xml</dcterms:medium>
> >    <dc:identifier xsi:type="dcterms:URI">http://www.recordare.
> com/</dc:identifier>
> >    <dc:source xsi:type="dcterms:URI">http://www.recordare.com/</dc:source>
> >    <dc:language xsi:type="dcterms:RFC4646">und</dc:language>
> >    <dc:rights>Copyright © 2002 Recordare LLC</dc:rights>
> >    <osfmeta:meter>
> >       <osfmeta:beats>2</osfmeta:beats>
> >       <osfmeta:beat-type>4</osfmeta:beat-type>
> >    </osfmeta:meter>
> >    <osfmeta:key>
> >       <osfmeta:root>A</osfmeta:root>
> >       <osfmeta:mode>major</osfmeta:mode>
> >    </osfmeta:key>
> > </osfmeta:osf-package-metadata-baseline>
> >
> > It sure looks to me like dcterms is declared! And again, it validates
> > fine on Windows, but not on the Mac system.
> >
> > So what might be happening differently between the two systems? The
> > Windows system is running Java 6 while the Mac is running Java 5. But
> > both systems are using Xerces Java 2.9.1. Validation is being done
> > with the javax.xml.validation.Validator Maybe one of the systems is
> > actually pulling in a different SchemaFactory oe Validator? Maybe
> > there are different configuration defaults between systems for the
> > SchemaFactory, Schema, and/or Validator classes?
> >
> > All the schemas, both top-level and imported, are supplied in local
> > versions. I double-checked and the LSResourceResolver is resolving
> > correctly both on Windows and Mac. The metadata.xsd file is available
> > in the Open Score Format SVN repository; I've temporarily put a copy
> > at http://www.recordare.com/xsd/metadata.xsd.
> >
> > I'm still pretty new to the area of namespace-aware XSD schema
> > validation in Java. I get the feeling that I am missing some
> > boilerplate / configuration code, but after checking online
> > documentation and doing web searches, I still do not know where that
> > might be.
> >
> > Thanks for any advice on how to fix this up, or how to approach
> fixing this up!
> >
> > Best regards,
> >
> > Michael Good
> > Recordare LLC
> > www.recordare.com
> >
> > _______________________________________________________________________
> >
> > XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> > to support XML implementation and development. To minimize
> > spam in the archives, you must subscribe before posting.
> >
> > [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> > Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> > subscribe: xml-dev-subscribe@lists.xml.org
> > List archive: http://lists.xml.org/archives/xml-dev/
> > List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
> >
>
> _______________________________________________________________________
>
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
>
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php


[1] http://markmail.org/message/bntj64gxademl5ex

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com

E-mail: mrglavas@apache.org



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS