You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by "Amit Nithian (JIRA)" <ji...@apache.org> on 2008/08/21 23:48:44 UTC

[jira] Created: (SOLR-712) Support for relative path XML Entity Includes

Support for relative path XML Entity Includes
---------------------------------------------

                 Key: SOLR-712
                 URL: https://issues.apache.org/jira/browse/SOLR-712
             Project: Solr
          Issue Type: Improvement
    Affects Versions: 1.2, 1.3
            Reporter: Amit Nithian
            Priority: Minor
             Fix For: 1.2
         Attachments: XMLEntityInclude.tgz

This patch modifies the Config.java and IndexSchema.java to support XML entity includes of relative paths. When parsing an InputStream not providing a SystemID (i.e. base path for example) to the DOM parser will basically force all entity includes to be relative to the base project directory rather than the directory hosting the document. This patch simply passes in the configuration directory as the systemID thus making the entity includes relative to the home of solrconfig.xml and schema.xml. 

The IndexSchema.java was modified to ensure objects do NOT process the xml:base attribute. Newer Xerces-J parsers allow for the removal of this attribute in the DOM (by setting the appropriate feature); however, the DOM parser used by Java 5 doesn't support this feature.

For example:
Without the entity include, if my Solr app was running on C:\solr, then any entity includes would have to be relative to C:\solr regardless of solrconfig.xml and schema.xml. This patch allows for includes relative to the conf directory of solr.home (i.e. ../../my_base_schema.xml) would be located two directories above "conf".

Please submit improvements or comments on this patch. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (SOLR-712) Support for relative path XML Entity Includes

Posted by "Henri Biestro (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SOLR-712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625099#action_12625099 ] 

henrib edited comment on SOLR-712 at 8/23/08 12:33 PM:
--------------------------------------------------------------

Amit, 
I reused your good idea in SOLR-646 and added an entity resolver so we can put properties (variables) to get to the resource.
The crux of it is in Config.java ctor:
{code}
    final SolrResourceLoader eloader = loader;
    EntityResolver esolver = new EntityResolver() {
      public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
        if (systemId != null && systemId.startsWith("solr:")) {
          String res = systemId.substring(5);
          res = DOMUtil.substituteProperty(res, eloader.getProperties());
          return new InputSource(eloader.openResource(res));
        }
        return null;
      }
    };
....

    javax.xml.parsers.DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    builder.setEntityResolver(esolver);
...
{code}
Oh, and I remove systematically xml:base form DOMUtil.toMapExcept
Thanks again.


      was (Author: henrib):
    Amit, 
I reused your good idea and added an entity resolver so we can put properties (variables) to get to the resource.
The crux of it is in Config.java ctor:
{code}
    final SolrResourceLoader eloader = loader;
    EntityResolver esolver = new EntityResolver() {
      public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
        if (systemId != null && systemId.startsWith("solr:")) {
          String res = systemId.substring(5);
          res = DOMUtil.substituteProperty(res, eloader.getProperties());
          return new InputSource(eloader.openResource(res));
        }
        return null;
      }
    };
....

    javax.xml.parsers.DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    builder.setEntityResolver(esolver);
...
{code}
Oh, and I remove systematically xml:base form DOMUtil.toMapExcept
Thanks again.

  
> Support for relative path XML Entity Includes
> ---------------------------------------------
>
>                 Key: SOLR-712
>                 URL: https://issues.apache.org/jira/browse/SOLR-712
>             Project: Solr
>          Issue Type: Improvement
>    Affects Versions: 1.2, 1.3
>            Reporter: Amit Nithian
>            Priority: Minor
>             Fix For: 1.2
>
>         Attachments: XMLEntityInclude.tgz
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> This patch modifies the Config.java and IndexSchema.java to support XML entity includes of relative paths. When parsing an InputStream not providing a SystemID (i.e. base path for example) to the DOM parser will basically force all entity includes to be relative to the base project directory rather than the directory hosting the document. This patch simply passes in the configuration directory as the systemID thus making the entity includes relative to the home of solrconfig.xml and schema.xml. 
> The IndexSchema.java was modified to ensure objects do NOT process the xml:base attribute. Newer Xerces-J parsers allow for the removal of this attribute in the DOM (by setting the appropriate feature); however, the DOM parser used by Java 5 doesn't support this feature.
> For example:
> Without the entity include, if my Solr app was running on C:\solr, then any entity includes would have to be relative to C:\solr regardless of solrconfig.xml and schema.xml. This patch allows for includes relative to the conf directory of solr.home (i.e. ../../my_base_schema.xml) would be located two directories above "conf".
> Please submit improvements or comments on this patch. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SOLR-712) Support for relative path XML Entity Includes

Posted by "Amit Nithian (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SOLR-712?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Amit Nithian updated SOLR-712:
------------------------------

    Attachment: XMLEntityInclude.tgz

Patch in support of this improvement.

> Support for relative path XML Entity Includes
> ---------------------------------------------
>
>                 Key: SOLR-712
>                 URL: https://issues.apache.org/jira/browse/SOLR-712
>             Project: Solr
>          Issue Type: Improvement
>    Affects Versions: 1.2, 1.3
>            Reporter: Amit Nithian
>            Priority: Minor
>             Fix For: 1.2
>
>         Attachments: XMLEntityInclude.tgz
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> This patch modifies the Config.java and IndexSchema.java to support XML entity includes of relative paths. When parsing an InputStream not providing a SystemID (i.e. base path for example) to the DOM parser will basically force all entity includes to be relative to the base project directory rather than the directory hosting the document. This patch simply passes in the configuration directory as the systemID thus making the entity includes relative to the home of solrconfig.xml and schema.xml. 
> The IndexSchema.java was modified to ensure objects do NOT process the xml:base attribute. Newer Xerces-J parsers allow for the removal of this attribute in the DOM (by setting the appropriate feature); however, the DOM parser used by Java 5 doesn't support this feature.
> For example:
> Without the entity include, if my Solr app was running on C:\solr, then any entity includes would have to be relative to C:\solr regardless of solrconfig.xml and schema.xml. This patch allows for includes relative to the conf directory of solr.home (i.e. ../../my_base_schema.xml) would be located two directories above "conf".
> Please submit improvements or comments on this patch. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SOLR-712) Support for relative path XML Entity Includes

Posted by "Henri Biestro (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SOLR-712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625099#action_12625099 ] 

Henri Biestro commented on SOLR-712:
------------------------------------

Amit, 
I reused your good idea and added an entity resolver so we can put properties (variables) to get to the resource.
The crux of it is in Config.java ctor:
{code}
    final SolrResourceLoader eloader = loader;
    EntityResolver esolver = new EntityResolver() {
      public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
        if (systemId != null && systemId.startsWith("solr:")) {
          String res = systemId.substring(5);
          res = DOMUtil.substituteProperty(res, eloader.getProperties());
          return new InputSource(eloader.openResource(res));
        }
        return null;
      }
    };
....

    javax.xml.parsers.DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    builder.setEntityResolver(esolver);
...
{code}
Oh, and I remove systematically xml:base form DOMUtil.toMapExcept
Thanks again.


> Support for relative path XML Entity Includes
> ---------------------------------------------
>
>                 Key: SOLR-712
>                 URL: https://issues.apache.org/jira/browse/SOLR-712
>             Project: Solr
>          Issue Type: Improvement
>    Affects Versions: 1.2, 1.3
>            Reporter: Amit Nithian
>            Priority: Minor
>             Fix For: 1.2
>
>         Attachments: XMLEntityInclude.tgz
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> This patch modifies the Config.java and IndexSchema.java to support XML entity includes of relative paths. When parsing an InputStream not providing a SystemID (i.e. base path for example) to the DOM parser will basically force all entity includes to be relative to the base project directory rather than the directory hosting the document. This patch simply passes in the configuration directory as the systemID thus making the entity includes relative to the home of solrconfig.xml and schema.xml. 
> The IndexSchema.java was modified to ensure objects do NOT process the xml:base attribute. Newer Xerces-J parsers allow for the removal of this attribute in the DOM (by setting the appropriate feature); however, the DOM parser used by Java 5 doesn't support this feature.
> For example:
> Without the entity include, if my Solr app was running on C:\solr, then any entity includes would have to be relative to C:\solr regardless of solrconfig.xml and schema.xml. This patch allows for includes relative to the conf directory of solr.home (i.e. ../../my_base_schema.xml) would be located two directories above "conf".
> Please submit improvements or comments on this patch. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SOLR-712) Support for relative path XML Entity Includes

Posted by "Shalin Shekhar Mangar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SOLR-712?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Shalin Shekhar Mangar updated SOLR-712:
---------------------------------------

    Fix Version/s:     (was: 1.2)
                   1.4

Changing fix versions to 1.4 since it is now part of SOLR-646

> Support for relative path XML Entity Includes
> ---------------------------------------------
>
>                 Key: SOLR-712
>                 URL: https://issues.apache.org/jira/browse/SOLR-712
>             Project: Solr
>          Issue Type: Improvement
>    Affects Versions: 1.2, 1.3
>            Reporter: Amit Nithian
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: XMLEntityInclude.tgz
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> This patch modifies the Config.java and IndexSchema.java to support XML entity includes of relative paths. When parsing an InputStream not providing a SystemID (i.e. base path for example) to the DOM parser will basically force all entity includes to be relative to the base project directory rather than the directory hosting the document. This patch simply passes in the configuration directory as the systemID thus making the entity includes relative to the home of solrconfig.xml and schema.xml. 
> The IndexSchema.java was modified to ensure objects do NOT process the xml:base attribute. Newer Xerces-J parsers allow for the removal of this attribute in the DOM (by setting the appropriate feature); however, the DOM parser used by Java 5 doesn't support this feature.
> For example:
> Without the entity include, if my Solr app was running on C:\solr, then any entity includes would have to be relative to C:\solr regardless of solrconfig.xml and schema.xml. This patch allows for includes relative to the conf directory of solr.home (i.e. ../../my_base_schema.xml) would be located two directories above "conf".
> Please submit improvements or comments on this patch. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.