I've spent some time looking at various conversations on this problem,
but I can't find a solution that works.  XInclude has to point a valid
XML document, with a single root element.  It should be possible to
use xpointer to specify children elements to include, but as far as I
can tell, the xpointer support doesn't include any scheme complex
enough to express "all the child elements of a given element", which
is what I would like.

So, here's what I have (it's more complicated than necessary for this
example because I also want it to support includes for both the root
level and a sub-level to use when doing schema, as I want to do
particular fields, but not all of them in the include file):

<<includes.dtd>>

<!ELEMENT includes (include+)>
<!ELEMENT include ANY>
<!ATTLIST include id ID #REQUIRED>

<<solrconfigIncludes.xml>>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE includes SYSTEM "includes.dtd">
<includes>
        <include id="root">
...several elements to be included at the root of a solrconfig.xml file...
        </include>
</includes>

<<solrconfig.xml>>

<?xml version="1.0" encoding="UTF-8" ?>
<config>
        <xi:include href="../../conf/solrconfigIncludes.xml" xpointer="root"
xmlns:xi="http://www.w3.org/2001/XInclude"; />

        <requestHandler name="dismax" class="solr.SearchHandler">
                <lst name="defaults">
                        <str name="defType">dismax</str>
                        <str name="echoParams">explicit</str>
                        <float name="tie">0.01</float>
                        <str name="qf">all_text</str>
                        <str name="pf">all_text</str>
                        <str 
name="bf">recip(ms(NOW,dateoccurredboost),3.16e-11,1,1)</str>
                        <str name="fl"></str>
                        <str name="mm">1&lt;-1 4&lt;-2</str>
                        <int name="ps">100</int>
                        <str name="q.alt">*:*</str>
                        <str name="hl.fl">highlight</str>
                </lst>

                <arr name="last-components">
                        <str>spellcheck</str>
                </arr>
        </requestHandler>
</config>

So, that xpointer="root", unfortunately, grabs the <include id="root">
element, but what I need, of course, is the contents of that element
(the children).

I see this post:
http://lucene.472066.n3.nabble.com/including-external-files-in-config-by-corename-td698324.html
that implies you can use #xpointer(/*/node()) to get all elements of
the root node (like if I changed my example to only have one include,
and just used multiple files, which is fine if it works), however my
testing gave this error: ERROR org.apache.solr.core.CoreContainer -
org.xml.sax.SAXParseException: Fragment identifiers must not be used.
The 'href' attribute value
'../../conf/solrconfigIncludes.xml#xpointer(root/node())' is not
permitted.  I tried several other variations of trying to come up with
pointers using node() or *, none of which worked.

And I also see this post:
http://lucene.472066.n3.nabble.com/solrconfig-xml-and-xinclude-td984058.html
that shows off a cumbersome way to list out each child element by
index number using the element scheme, which I assume works, but is
way to cumbersome to use.

Does any have any success using XInclude to include more than one
element?  I'm open to any and all approaches to having
partially-common configuration between cores.

Thanks,
Stephen

--
Stephen Duncan Jr
www.stephenduncanjr.com

Reply via email to