4

For example, I want instead of referring to an online XSD like this:

<persistence xmlns="…" xmlns:xsi="…"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
    http://www.oracle.com/…/persistence_2_1.xsd">  <!-- online -->

To refer to a classpath XSD like this:

<persistence xmlns="…" xmlns:xsi="…"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
    org/hibernate/jpa/persistence_2_1.xsd">   <!-- classpath -->
Ori Popowski
  • 10,432
  • 15
  • 57
  • 79
  • Use an XML Catalog. See also http://stackoverflow.com/questions/8412798/how-to-load-xmlcatalog-from-classpath-resources-inside-a-jar-reliably – Harald Wellmann Feb 01 '15 at 20:45

2 Answers2

3

There's no standardized way of doing this. Some products may support classpath URIs: classpath:org/hibernate/jpa/persistence_2_1.xsd. If your product doesn't, you can probably write a plugin (LSResourceResolver) that enables the capability.

Jens
  • 67,715
  • 15
  • 98
  • 113
Michael Kay
  • 156,231
  • 11
  • 92
  • 164
3

My team had problem that Spring Boot couldn't find schema for Spring profiled unit tests when xsi:schemaLocation was provided as classpath:xmlschemas/requiredSchema.xsd

After hours of debugging the solution was to use relative path:

/xmlschemas/requiredSchema.xsd

(xmlschemas directory was in resources root)

komidawi
  • 386
  • 3
  • 8