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?
I was able to achieve this by importing one schema into the other.
e.g.
<xs:import namespace="http://base.google.com/ns/1.0" schemaLocation="public/xsd/google_base.xsd"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With