Re: [nokogiri-talk] XML Schema Parsing Error

1,301 views
Skip to first unread message

Mike Dalessio

unread,
Jun 14, 2012, 2:41:20 PM6/14/12
to nokogi...@googlegroups.com


On Wed, Jun 13, 2012 at 11:50 PM, genexp <bcorr...@gmail.com> wrote:
Hi Folks - 

I'm having a problem parsing a schema file.  I'm at a loss.  Here's the error I'm getting:

[4] pry(main)> xsd = Nokogiri::XML::Schema(File.read('lib/rua.xsd'))                                                                                                                                        
Nokogiri::XML::SyntaxError: Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'type': References from this schema to components in no namespace are not allowed, since not indicated by an import statement.
from [path omitted]/nokogiri-1.5.3/lib/nokogiri/xml/schema.rb:37:in `from_document'

I'm not an XSD expert by any means, but I believe you have to use an <import> tag to reference a component.

You might find http://www.xfront.com/HideVersusExpose.html enlightening; or maybe not.

HTH,
-m

genexp

unread,
Jun 14, 2012, 11:02:58 PM6/14/12
to nokogi...@googlegroups.com
Hey Mike - Thanks very much for the response!  I'll try to find an XSD export around (obviously I'm not one either).  Interestingly, this file does pass the XSD validator provided by W3C (http://www.w3.org/2001/03/webdata/xsv)  If I can find more info I'll update the thread.  

As an aside, it would be nice if Nokogiri would note the line number in the original document that its unhappy with.  Is there some way to make that happen?

Best,
Brian

genexp

unread,
Jun 15, 2012, 12:12:26 AM6/15/12
to nokogi...@googlegroups.com
Mike - I figured it out.  Looks like I needed to specify the default namespace for this document, setting it equal to the targetNamespace.  

This fixes it.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://dmarc.org/dmarc-xml/0.1"

If XML is like violence, I think I just killed this one :)

Thanks for the pointer, it helped me fix it!

B
Reply all
Reply to author
Forward
0 new messages