Consider an XML document that starts as follows with several schemas (this is NOT a Spring-specific question, this is just a handy XML document for example):
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:osgi="http://www.springframework.org/schema/osgi" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
I want to check the document, but I don’t know in advance which namespaces the document author will use. I trust the author of the document, so I am ready to download arbitrary URLs to the scheme. How to implement my validator?
I know that I can specify my schemas with an instance of DocumentBuilderFactory for my setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", new String[] {...}) call setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", new String[] {...}) , but I I don’t know the URL of the schema until the document is parsed.
Of course, I was able to extract the XSD URL myself after parsing the document, and then run it through the validator, specifying "http://java.sun.com/xml/jaxp/properties/schemaSource" as mentioned above, but of course already exists an implementation that does this automatically?
source share