Xml XSL转换无法使用Solr中的XPathEntityProcessor返回值
我正在尝试将XSL选项与XpathEntityProcessor一起使用,以从xml转换中选择数据。配置运行时不会出错,但不会返回任何值。在这一点上,只要让它为下面的IUPAC实体的一个单词编制索引就可以了。所有其他实体都按预期工作。我想使用XSL选项,这样我就可以完全访问XPATH,以便做出特定的选择。数据杂乱无章,需要使用javascript或正则表达式进行进一步处理 我的实体看起来像这样Xml XSL转换无法使用Solr中的XPathEntityProcessor返回值,xml,debugging,xslt,solr,dataimporthandler,Xml,Debugging,Xslt,Solr,Dataimporthandler,我正在尝试将XSL选项与XpathEntityProcessor一起使用,以从xml转换中选择数据。配置运行时不会出错,但不会返回任何值。在这一点上,只要让它为下面的IUPAC实体的一个单词编制索引就可以了。所有其他实体都按预期工作。我想使用XSL选项,这样我就可以完全访问XPATH,以便做出特定的选择。数据杂乱无章,需要使用javascript或正则表达式进行进一步处理 我的实体看起来像这样 <document> <!-- this outer process
<document>
<!-- this outer processor generates a list of files satisfying the conditions
specified in the attributes -->
<entity
name="f"
processor="FileListEntityProcessor"
fileName=".*xml"
newerThan="'NOW-30YEARS'"
recursive="true"
rootEntity="false"
dataSource="null"
baseDir="C:\DrugLabels\Prescription\Test"
transformer="RegexTransformer,TemplateTransformer">
<!-- this strips the file extension and sets the id = the file name -->
<field column="file" regex="^(.*)/|.xml" replaceWith="$1" name="id"/>
<!-- this processor extracts content using Xpath from each file found -->
<entity
name="DrugLabel"
processor="XPathEntityProcessor"
forEach="/document"
url="${f.fileAbsolutePath}">
<entity
name="document_title"
processor="XPathEntityProcessor"
transformer="script:lineToTitleCase"
forEach="/document"
url="${f.fileAbsolutePath}">
<field column="title" xpath="/document/title"/>
</entity>
<entity
name="ingredients"
processor="XPathEntityProcessor"
transformer="script:listToTitleCase"
forEach="/document"
url="${f.fileAbsolutePath}">
<field column="generic_medicine" xpath="/document/component/structuredBody/component/section/subject/manufacturedProduct/manufacturedProduct/asEntityWithGeneric/genericMedicine/name"/></entity>
</entity>
<entity
name="IUPAC"
processor="XPathEntityProcessor"
transformer="RegexTransformer, script:debug"
forEach="/add"
url="${f.fileAbsolutePath}"
xsl="C:\solr-4.3.1\example\solr\DrugLabels\conf\section-description-transform.xsl">
<field column="chemical_name" xpath="/add/doc/field/@chemical_name" flatten="true"/>
</entity>
</entity>
</entity>
</document>
以及输出:
"chemical_name": [
"value: function toString() {/*\njava.lang.String toString()\n*/}\n"
这可能也有帮助
function debug(row) {
var r = row.get('chemical_name').toString;
r = 'value: ' + r;
row.put('chemical_name', r);
return row;
}
"chemical_name": [
"value: function toString() {/*\njava.lang.String toString()\n*/}\n"
<xsl:template match="/">
<add>
<xsl:for-each select="document/entity">
<doc>
<xsl:for-each select=".//field">
<field name="{@column}"><xsl:value-of select="@xpath"/></field>
</xsl:for-each>
</doc>
</xsl:for-each>
</add>
</xsl:template>