How to include another XML file from Solr schema.xml file?

I have several different cores, each with its own circuit, but they all have the same field types. I would like to remove duplicate field type declarations and do something like this in my schema.xml files:

<?xml version="1.0" encoding="UTF-8" ?> <schema name="foo" version="1.5"> <fields> <field name="_version_" ... <field name="id" ... ... </fields> <uniqueKey>id</uniqueKey> <include "/path/to/field_types.xml"> </schema> 

I do not see in the documents any mechanism for doing this. I found one post citing this:

  <xi:include href="/path/to/field_types.xml" /> 

But it gives me a run error: The prefix "xi" for element "xi:include" is not bound.

Does anyone have an idea how to execute this type of raw?

+4
source share
2 answers

From now on, the Solr problem is SOLR-3087 , it seems that <xi:include> is the correct syntax, you just need to include the xi link to the inline namespace.

 <?xml version="1.0" encoding="UTF-8" ?> <schema name="foo" version="1.5"> <fields> <field name="_version_" ... <field name="id" ... ... </fields> <uniqueKey>id</uniqueKey> <xi:include href="/path/to/field_types.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> </schema> 
+7
source

Another clean solution to this problem is to add resources as external objects:

 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE schema [ <!ENTITY schemafieldtypes SYSTEM "schemafieldtypes.xml"> ]> 

then in xml you can add everywhere:

 &schemafieldtypes; 
+2
source

Source: https://habr.com/ru/post/1484888/


All Articles