简体   繁体   English

为什么我的 xml 和 xslt 条件满足时链接不了?

[英]Why won't my xml and xslt link if the conditions are met?

as it says in the title my xml does not read my xslt, I want to make a list taking the "first name" and "last name" but it doesn't work for me, I don't know if I'm making a mistake when putting the name or maybe I'm not doing well, saying that everything is stored in the same folder so there should be no problem but there is.正如标题中所说,我的 xml 没有读取我的 xslt,我想制作一个包含“名字”和“姓氏”的列表,但它对我不起作用,我不知道我是否正在制作输入名称时出错,或者我可能做得不好,说所有内容都存储在同一个文件夹中,所以应该没有问题,但确实存在。 I am attaching my xml and xslt to see if I am getting something wrong:我附上我的 xml 和 xslt 看看我是否有问题:

xml name "comunidad": xml 名称“comunidad”:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="datos.xslt"?>
<comunidad fecha_actualizacion="2020-01-20T08:00:00">
    <propietarios>
        <propietario id="JMMM" apellidos="Mendoza Martínez" nombre="José Manuel" alcorriente="true" />
        <propietario id="AFGL" apellidos="Gálvez Lorente" nombre="Ana Francisca" alcorriente="true" />
        <propietario id="CNAA" apellidos="Casas Nuevas" nombre="Alfredo Arturo" alcorriente="true" />
        <propietario id="CEGL" apellidos="Gómez López" nombre="Cristina Elena" alcorriente="true" />
        <propietario id="GRNC" apellidos="Navas Conesa" nombre="Gregorio Rodrigo" />
        <propietario id="IPUL" apellidos="Usillos Liarte" nombre="Ignacio Patricio" />
    </propietarios>
    <propiedades>
        <propiedad id="C01" tipo="vivienda120" contacto="CNAA">
            <participacion propietario="CNAA" porcentaje="50" />
            <participacion propietario="AFGL" porcentaje="50" />
        </propiedad>
        <propiedad id="C02" tipo="vivienda90">
            <participacion propietario="GRNC" porcentaje="100" />
        </propiedad>
        <propiedad id="C03" tipo="vivienda90" contacto="CEGL">
            <participacion propietario="IPUL" porcentaje="50" />
            <participacion propietario="CEGL" porcentaje="50" />
        </propiedad>
        <propiedad id="C04" tipo="vivienda150">
            <participacion propietario="JMMM" porcentaje="100" />
        </propiedad>
        <propiedad id="G01" tipo="garaje" contacto="CNAA">
            <participacion propietario="CNAA" porcentaje="50" />
            <participacion propietario="AFGL" porcentaje="50" />
        </propiedad>
        <propiedad id="G02" tipo="garaje">
            <participacion propietario="JMMM" porcentaje="100" />
        </propiedad>
    </propiedades>
    <cuotas>
        <cuota tipo="vivienda90" valor="35.0" />
        <cuota tipo="vivienda120" valor="45.0" />
        <cuota tipo="vivienda150" valor="50.0" />
        <cuota tipo="garaje" valor="15.0" />
    </cuotas>
    <derramas>
        <derrama id="D001" valor="20.0" asunto="Arreglos fachada" desde="2019-10-01" hasta="2020-09-01">
        Se ha procedido a restaurar la fachada completa, usando mortero monocapa,
        según acuerdo de junta ordinaria de la fecha 15/07/2019.
        </derrama>
    </derramas>
</comunidad>

and xslt called datos:和 xslt 称为 datos:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="/">

<html>
    <body>
        <h3>Listado de ropietarios al corriente de pago</h3>
        <xsl:for-each select="/comunidad/propietarios/propietario[@alcorriente]">
            <ul>
                <li><xsl:value-of select="@nombre"></li>
                <li><xsl:value-of select="@apellidos"></li>
            </ul>
        </xsl:for-each>
    </body>
</html>
</xsl:template>
</xsl:stylesheet>

You are not closing the xsl:value-of elements properly, and the reason you are not getting a useful error message is perhaps because you are running this in a browser.您没有正确关闭xsl:value-of元素,并且您没有收到有用的错误消息的原因可能是因为您正在浏览器中运行它。

Corrected XSLT Stylesheet更正了 XSLT 样式表

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="/">

<html>
    <body>
        <h3>Listado de ropietarios al corriente de pago</h3>
        <xsl:for-each select="/comunidad/propietarios/propietario[@alcorriente]">
            <ul>
                <li><xsl:value-of select="@nombre"/></li>
                <li><xsl:value-of select="@apellidos"/></li>
            </ul>
        </xsl:for-each>
    </body>
</html>
</xsl:template>
</xsl:stylesheet>

HTML Output HTML Output

<html>
   <body>
      <h3>Listado de ropietarios al corriente de pago</h3>
      <ul>
         <li>José Manuel</li>
         <li>Mendoza Martínez</li>
      </ul>
      <ul>
         <li>Ana Francisca</li>
         <li>Gálvez Lorente</li>
      </ul>
      <ul>
         <li>Alfredo Arturo</li>
         <li>Casas Nuevas</li>
      </ul>
      <ul>
         <li>Cristina Elena</li>
         <li>Gómez López</li>
      </ul>
   </body>
</html>

Additional tip: if your browser does not display the desired results, run the same transformation elsewhere, for instance with this online tool here: http://xsltransform.net/ .附加提示:如果您的浏览器未显示所需结果,请在其他地方运行相同的转换,例如使用此在线工具: http://xsltransform.net/ In many cases, such a tool will display a more helpful error message.在许多情况下,此类工具会显示更有用的错误消息。


If that does not solve your problem then perhaps the XSLT file has a different name or is not available.如果这不能解决您的问题,那么 XSLT 文件可能具有不同的名称或不可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM