【问题标题】:xforms rendered via xslt and xml error通过 xslt 和 xml 错误呈现的 xforms
【发布时间】:2011-11-28 23:13:31
【问题描述】:

我知道这个问题听起来像是“过去”的事情,但我需要做这个作为家庭作业,但我做不到。

问题如下:

我有从数据库调用的 xml 数据,我使用 xslt 在浏览器上呈现 xforms 文档,顺便说一下,它安装的旧 firefox 3.6 仅用于使用 xforms 扩展。 它正确呈现 xforms 文档,但控件无法按预期工作,我无法提交表单,并且实例数据未填写输入。

我的 xsl 样式表如下:

<xsl:stylesheet version="1.0"
            xmlns="http://www.w3.org/1999/xhtml"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:xf="http://www.w3.org/2002/xforms">
<xsl:output method="xml"
indent="yes"
omit-xml-declaration="yes"
media-type="application/xhtml+xml"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />
<xsl:template match="/">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" dir="ltr" lang="es">
        <head>
            <xf:model>
                <xf:instance>
                    <data xmlns="">
                        <iCargo_Id>1</iCargo_Id>
                        <sCargo_Desc>lalala</sCargo_Desc>
                        <iConcurrencia_Id>1</iConcurrencia_Id>
                    </data>
                </xf:instance>
                <xf:submission id="prueba" action="EditarCargos.aspx" method="post"/>
            </xf:model>

            <link href="../css/style.css" rel="stylesheet" type="text/css" />
            <title><![CDATA[Adicionar Cargos]]></title>
        </head>
        <body>
            <div class="header"></div>
            <div class="menu">
                <a href="../empleados/editarempleados.aspx"><![CDATA[Empleados]]></a>
                <a href="../horarios/editarhorarios.aspx"><![CDATA[Horarios]]></a>
                <a href="../jornadas/editarjornadas.aspx"><![CDATA[Jornadas]]></a>
                <a href="../cargos/editarcargos.aspx"><![CDATA[Cargos]]></a>
                <a href="../usuarios/editarusuarios.aspx"><![CDATA[Usuarios]]></a>
                <a href="../profesiones/editarprofesiones.aspx"><![CDATA[Profesiones]]></a>
                <a href="../reportes/ReporteMarcaciones.aspx"><![CDATA[Rep. de Marcaciones]]></a>
                <a href="../cerrarSesion.aspx"><![CDATA[Cerrar Sesión]]></a>
            </div>
            <div id="main">
                <div class="mainTitle">
                    <![CDATA[Adicionar Cargos]]>
                </div>
                <div>
                    <xf:input ref="sCargo_Desc">
                        <xf:label><![CDATA[Cargo]]></xf:label>
                    </xf:input>
                    <div>
                        <xf:submit submission="prueba">
                            <xf:label><![CDATA[Guardar Cambios]]></xf:label>
                        </xf:submit>
                    </div>
                </div>
                <div>

                    <a class="cmdSecond" href="EditarCargos.aspx"><![CDATA[Volver]]></a>
                </div>
            </div>
        </body>
    </html>
</xsl:template>
<xsl:template match="cargo[iCargo_Id]">
    <iCargo_Id>
        <xsl:value-of select="iCargo_Id"/>
    </iCargo_Id>
    <sCargo_Desc>
        <xsl:value-of select="sCargo_Desc"/>
    </sCargo_Desc>
    <iConcurrencia_Id>
        <xsl:value-of select="iConcurrencia_Id"/>
    </iConcurrencia_Id>
</xsl:template>
<xsl:template match="cargo[not(iCargo_Id)]">
    <iCargo_Id></iCargo_Id>
    <sCargo_Desc></sCargo_Desc>
    <iConcurrencia_Id></iConcurrencia_Id>
</xsl:template>
</xsl:stylesheet>

我的 xml 代码如下所示:

<cargo>
    <iCargo_Id>1</iCargo_Id>
    <sCargo_Desc>Jefe de Sistemas</sCargo_Desc>
    <iConcurrencia_Id>1</iConcurrencia_Id>
</cargo>

我认为问题在于&lt;xsl:output method="xml" 属性 , 因为 xforms 需要 xhtml 来渲染,但是 firefox 在我做的时候会抛出 XSLT 异常。

请帮忙!我到处搜索,发现它与 Firefox 中的一个错误有关,但我希望有另一种方法可以使这项工作,您的帮助将非常感激,并对我的英语感到抱歉,我目前正在学习:D

【问题讨论】:

  • 没有xhtml输出这样的东西。它可以是 xml、html、文本。 Firefox 支持 html/xml。
  • @FailedDev,你的意思是XSLT 1.0中没有xhtml输出方法吗?这是真的,但是您可以从 XSLT 1.0 输出 XHTML,因为它是 XML。所以我不确定你在说什么。
  • 您可以尝试使用另一个 XSLT 处理器进行转换——尤其是使用可以指定&lt;xsl:output method="xhtml"/&gt; 的 XSLT 2.0 处理器——然后尝试查看生成的结果是否具有预期的行为。如果不是这样,那么您对问题原因的假设是错误的。
  • P.S.我使用 Saxon 验证了您的样式表,它说样式表是有效的。因此,请说明您所说的“XSLT 异常”是什么意思。
  • @jmacboy 如果您已解决问题,请将解决方案作为答案发布,并接受它。这会将其从未答复列表中删除,并帮助遇到相同问题的其他人。

标签: html xml xhtml xslt xforms


【解决方案1】:

好的,我没有找到解决方案,但使用了解决方法来完成这项工作。

由于 Firefox 的问题,我不得不以另一种方式呈现样式表,所以我使用 aspnet 在后面的代码中预呈现样式表(我忘了提到我正在使用它),然后我写了它使用 Response.Write 到页面,它使用 html 作为 xsl:output 方法就像一个魅力

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    相关资源
    最近更新 更多