- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
全部。我有一个非常大的问题,我想询问信息,请。我有一个java项目,这个项目的功能之一就是必须解析一些xls。好吧,我在解析时遇到了问题。这是解析 xsls 的循环:
while(itera.hasNext()){
// Creacion del transformador de SAX
tFactory.setErrorListener(new ManejadorXSLTErrores());
String nombrePlantilla = (String)itera.next();
//creamos el objeto transformer
String stream = (String)plantillas.get(nombrePlantilla);
if((stream!= null) && (getClass()!=null) && (getClass().getResourceAsStream(stream)!=null))
reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(stream)));
else
throw new ExceptionErrorARQSD(ConstantesErrorSD.ERROR_XML_TRANSFORMACION,new String[]{"Error al obtener el StreamSource: "+stream},null);
transformer = tFactory.newTemplates(new StreamSource(reader));
//se guardan en un contenedor
contenedortransformers.putElemento(nombrePlantilla,transformer);
}
这是我的 Excel 的 xsd 的一部分:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xalan="http://xml.apache.org/xslt">
<xsl:param name="servicio">
<xsl:value-of select="normalize-space(/SD/MENSAJECM/contenedorPeticionDatosComunes/codigoServicio)"/>
</xsl:param>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="SD">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="MENSAJECM">
<xsl:if test="$servicio = 'NSPLA001'">
<xsl:element name="MensajeSolicitud">
<xsl:apply-templates/>
</xsl:element>
</xsl:if>
<xsl:if test="$servicio = 'NSPLA002'">
<xsl:apply-templates/>
</xsl:if>
</xsl:template>
<xsl:template match="contenedorPeticionDatosComunes">
<xsl:if test="$servicio = 'NSPLA001'">
<xsl:param name="fecha"><xsl:value-of select="normalize-space(./fecha)"/></xsl:param>
<xsl:param name="hora"><xsl:value-of select="normalize-space(./hora)"/></xsl:param>
<!-- Cod. Entidad U.O.R. (csbc) -->
<xsl:attribute name="csbc">
<xsl:value-of select="substring(./unidadOrganizativaResponsable,1,4)"/>
</xsl:attribute>
<xsl:attribute name="fecha_envio">
<xsl:value-of select="$fecha"/>
</xsl:attribute>
<xsl:attribute name="oficina">
<xsl:value-of select="substring(./unidadOrganizativaResponsable,5,4)"/>
</xsl:attribute>
<xsl:attribute name="terminal">
<xsl:value-of select="substring(./unidadOrganizativaResponsable,11,2)"/>
</xsl:attribute>
<xsl:attribute name="usuario">
<xsl:value-of select="./usuario"/>
</xsl:attribute>
<xsl:attribute name="version">
<xsl:value-of select="1.0"/>
</xsl:attribute>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
这是我收到的异常:
javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: ¡xsl:param no está permitido en esta posición de la hoja de estilos!
javax.xml.transform.TransformerException: ¡xsl:param no está permitido en esta posición de la hoja de estilos!
谁能帮帮我???谢谢
最佳答案
是的,为了让它与 if 一起工作,你应该使用试试这个:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xalan="http://xml.apache.org/xslt">
<xsl:param name="servicio">
<xsl:value-of select="normalize-space(/SD/MENSAJECM/contenedorPeticionDatosComunes/codigoServicio)"/>
</xsl:param>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="SD">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="MENSAJECM">
<xsl:if test="$servicio = 'NSPLA001'">
<xsl:element name="MensajeSolicitud">
<xsl:apply-templates/>
</xsl:element>
</xsl:if>
<xsl:if test="$servicio = 'NSPLA002'">
<xsl:apply-templates/>
</xsl:if>
</xsl:template>
<xsl:template match="contenedorPeticionDatosComunes">
<xsl:param name="fecha"><xsl:value-of select="normalize-space(./fecha)"/></xsl:param>
<xsl:param name="hora"><xsl:value-of select="normalize-space(./hora)"/></xsl:param>
<xsl:if test="$servicio = 'NSPLA001'">
<!-- Cod. Entidad U.O.R. (csbc) -->
<xsl:attribute name="csbc">
<xsl:value-of select="substring(./unidadOrganizativaResponsable,1,4)"/>
</xsl:attribute>
<xsl:attribute name="fecha_envio">
<xsl:value-of select="$fecha"/>
</xsl:attribute>
<xsl:attribute name="oficina">
<xsl:value-of select="substring(./unidadOrganizativaResponsable,5,4)"/>
</xsl:attribute>
<xsl:attribute name="terminal">
<xsl:value-of select="substring(./unidadOrganizativaResponsable,11,2)"/>
</xsl:attribute>
<xsl:attribute name="usuario">
<xsl:value-of select="./usuario"/>
</xsl:attribute>
<xsl:attribute name="version">
<xsl:value-of select="1.0"/>
</xsl:attribute>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
关于java - XSL,编译 javax.xml.transform.TransformerException 时出现问题 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39768334/
我正在使用javax.xml.transform.* 进行XSLT 转换。由于要使用的 xslt 文件来自外部世界,因此该文件中可能存在错误,我将向用户返回一些有意义的响应。 尽管我可以轻松捕获 Tr
我得到了javax.xml.transform.transformerException 当我尝试在 appium 中使用 xpath 识别元素时。下面是代码, driver.findElement(
这是我第一次使用 XPath,我正在尝试查询一个非常基本的示例。 String xml = "goodhi"; XPathFactory xpathFactory = XPathFac
全部。我有一个非常大的问题,我想询问信息,请。我有一个java项目,这个项目的功能之一就是必须解析一些xls。好吧,我在解析时遇到了问题。这是解析 xsls 的循环: while(itera.hasN
我正在使用 Apache FOP 生成 PDF。我想使用 unparsed-text() 函数读取 XSL 文件中的非 xml 文档。 在编写该函数后,我得到了这个错误。这是我的 XSL 文件。
我一直在尝试从 xml 文件中提取数据,但我一直收到此错误,我不确定自己做错了什么。 10-23 14:20:29.250: WARN/System.err(3541): --------------
我在 xsl 文件中放置了一个 javascript 函数。每当 onclick 事件触发时都必须调用此函数。 function embeddedPreview(sourc
我在最后一行代码中遇到异常 - Transformer transformer = TransformerFactory.newInstance().newTransformer(); DOMSour
我正在使用 JSoup 转换一些 HTML。生成最终的 HTML 后,我想将其呈现为 pdf 文件。为此,我使用 Flying Sacer 库。 我尝试渲染的 Html 示例: ... 将
Java xml出现错误 javax.xml.transform.TransformerException: java.lang.NullPointerException解决办法: 利用Java操
我正在使用 Mule CXF 组件从本地主机调用 Web 服务。被调用的Web服务返回一个SoapResult类型的对象,但Mule在转换它时,检测到返回类型为“[B”。最后,选择了 JAXBMars
我是一名优秀的程序员,十分优秀!