【发布时间】:2017-11-24 16:50:10
【问题描述】:
我正在尝试编写一个ìn xslt(1.0 版)转换器,它将输入的 xml 文件转换为另一种格式,运行一些写入 xml 文件的 xpath 查询。 Xpath 查询根据从 inptu 文件中检索到的系统和类型变量而变化。 我做到了:
<xsl:variable name="system" select="some path in input xml" />
<xsl:variable name="type" select="some path in input xml" />
一旦计算出系统和类型,我就可以将我的查询 xpath 检索为:
<xsl:variable name="metadata_mapping" select="some path in config xml based on system and type" />
如果我打印,一切看起来都很好:
<info>
<system>
<xsl:value-of select="$system" />
</system>
<type>
<xsl:value-of select="$type" />
</type>
metadata-mapping:
<xsl:value-of select="$metadata_mapping" />
</info>
当我尝试将 $metadata_mapping 评估为 xpath 查询时:
<xsl:value-of select="${metadata_mapping}" />
我收到以下错误:
17:19:44,508 错误 [main] JAXPSAXProcessorInvoker - org.apache.xml.utils.WrappedRuntimeException: Impossibile trovare la variabile con il nome {metadata_mapping} javax.xml.transform.TransformerException: org.apache.xml.utils.WrappedRuntimeException: Impossibile trovare la variabile con il nome {metadata_mapping} 在 org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:952) 在 org.apache.xalan.processor.TransformerFactoryImpl.newTransformerHandler(TransformerFactoryImpl.java:682) 在 org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.addStylesheet(JAXPSAXProcessorInvoker.java:137) 在 org.eclipse.wst.xsl.jaxp.debug.debugger.DebugRunner$1.addStylesheet(DebugRunner.java:327) 在 org.eclipse.wst.xsl.jaxp.debug.debugger.DebugRunner$1.addStylesheet(DebugRunner.java:318) 在 org.eclipse.wst.xsl.jaxp.debug.invoker.PipelineDefinition.addStyleSheet(PipelineDefinition.java:161) 在 org.eclipse.wst.xsl.jaxp.debug.invoker.PipelineDefinition.configure(PipelineDefinition.java:152) 在 org.eclipse.wst.xsl.jaxp.debug.debugger.DebugRunner.main(DebugRunner.java:359) 引起:org.apache.xml.utils.WrappedRuntimeException: Impossibile trovare la variabile con il nome {metadata_mapping} 在 org.apache.xpath.operations.Variable.fixupVariables(Variable.java:148) 在 org.apache.xpath.axes.FilterExprWalker.fixupVariables(FilterExprWalker.java:240) 在 org.apache.xpath.axes.WalkingIterator.fixupVariables(WalkingIterator.java:294) 在 org.apache.xpath.axes.WalkingIteratorSorted.fixupVariables(WalkingIteratorSorted.java:198) 在 org.apache.xpath.XPath.fixupVariables(XPath.java:88) 在 org.apache.xalan.templates.ElemValueOf.compose(ElemValueOf.java:183) 在 org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361) 在 org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366) 在 org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366) 在 org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366) 在 org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366) 在 org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366) 在 org.apache.xalan.templates.StylesheetRoot.recompose(StylesheetRoot.java:341) 在 org.apache.xalan.processor.StylesheetHandler.endDocument(StylesheetHandler.java:471) 在 com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endDocument(AbstractSAXParser.java:737) 在 com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:516) 在 com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808) 在 com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) 在 com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119) 在 com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) 在 com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522) 在 org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:922)
... 7 更多
org.apache.xml.utils.WrappedRuntimeException: Impossibile trovare la variabile con il nome {metadata_mapping} 在 org.apache.xpath.operations.Variable.fixupVariables(Variable.java:148) 在 org.apache.xpath.axes.FilterExprWalker.fixupVariables(FilterExprWalker.java:240) 在 org.apache.xpath.axes.WalkingIterator.fixupVariables(WalkingIterator.java:294) 在 org.apache.xpath.axes.WalkingIteratorSorted.fixupVariables(WalkingIteratorSorted.java:198) 在 org.apache.xpath.XPath.fixupVariables(XPath.java:88) 在 org.apache.xalan.templates.ElemValueOf.compose(ElemValueOf.java:183) 在 org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361) 在 org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366) 在 org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366) 在 org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366) 在 org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366) 在 org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:366) 在 org.apache.xalan.templates.StylesheetRoot.recompose(StylesheetRoot.java:341) 在 org.apache.xalan.processor.StylesheetHandler.endDocument(StylesheetHandler.java:471) 在 com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endDocument(AbstractSAXParser.java:737) 在 com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:516) 在 com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808) 在 com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) 在 com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119) 在 com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) 在 com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522) 在 org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:922) 在 org.apache.xalan.processor.TransformerFactoryImpl.newTransformerHandler(TransformerFactoryImpl.java:682) 在 org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.addStylesheet(JAXPSAXProcessorInvoker.java:137) 在 org.eclipse.wst.xsl.jaxp.debug.debugger.DebugRunner$1.addStylesheet(DebugRunner.java:327) 在 org.eclipse.wst.xsl.jaxp.debug.debugger.DebugRunner$1.addStylesheet(DebugRunner.java:318) 在 org.eclipse.wst.xsl.jaxp.debug.invoker.PipelineDefinition.addStyleSheet(PipelineDefinition.java:161) 在 org.eclipse.wst.xsl.jaxp.debug.invoker.PipelineDefinition.configure(PipelineDefinition.java:152) 在 org.eclipse.wst.xsl.jaxp.debug.debugger.DebugRunner.main(DebugRunner.java:359)
【问题讨论】: