views:

262

answers:

0

Hi

I'm generating a lot of XMPP stanzas, and want to validate them against the specs available here in my unit tests.

At the moment I am using Nokogiri to achieve this with something like

xml    = Nokogiri::XML( xmpp_stanza)
schema = Nokogiri::XML::Schema( xmpp_schema )

assert schema.valid?( xml )

Now this works fine except it gets reported as invalid because each schema only covers one namespace, and my XMPP stanzas have multiple namespaces. For example:

Invalid XML: Element '{http://jabber.org/protocol/pubsub}pubsub': No matching global element declaration available, but demanded by the strict wildcard.

How am I meant to handle multiple schemas to validate a single stanza? Am I meant to first split it apart by namespace and validate each one in isolation?