Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何使用XSLT添加条件表(或div),并确保文档格式良好_Html_Xml_Xslt 2.0 - Fatal编程技术网

Html 如何使用XSLT添加条件表(或div),并确保文档格式良好

Html 如何使用XSLT添加条件表(或div),并确保文档格式良好,html,xml,xslt-2.0,Html,Xml,Xslt 2.0,我想在表中添加coditional,但出现错误“error(0x80004005):样式表不包含文档元素。样式表可能为空,也可能不是格式良好的XML文档。” 我想要的是: <table> <!-- Start main table --> <tr> <td> <table> <tr> <th>...</th> <!-- This the table header, it can maybe b

我想在表中添加coditional,但出现错误“error(0x80004005):样式表不包含文档元素。样式表可能为空,也可能不是格式良好的XML文档。”

我想要的是:

<table> <!-- Start main table -->
<tr>
<td>
<table>
<tr>
<th>...</th>  <!-- This the table header, it can maybe better, but is not the issue -->
</tr>
</table>
</td>
</tr>

<!-- Here starts the issue first time-->

<x:if test="($ClickPeriod != '')" > <!-- if a new period (month, quater, or year is started, open new table -->
    <tr id="'$ClickPeriod'">
    <td>
    <table id="aRowList" class="Stripy" cellspacing="0" cellpadding="0" style="width:100%;"> <!-- subtable for every period-->
    </x:if>

    <x:for-each select="//ENTITY"> <!-- add one or more records -->
        <tr class="r{position() mod 2}">
            <td style="text-align:right; padding-right:10px;">
                ...
            </td>
        </tr>
    </x:for-each>

<!-- Here starts the issue second time-->

<x:if test="($LastPeriodRow !=  'True')" > <!-- if the this record is the last one of a period, close table -->
            </table>
        </td>
    </tr>
</x:if>
</table> <!-- End main table -->

...  
...
这样做的目的是,我可以使用jQuery隐藏一行“”,以便隐藏此行中的表

也许也可以使用div,但也有一个表头行。独立于此表头,必须能够隐藏子表中的不同行。 我尝试这种方式的原因是,它是框架的一部分。所有类型的css都已定义。我知道表格已经过时了,但它不是面向世界的web应用程序

没有人能帮我解决这个问题吗?我不是XSLT/XSD领域的专家

问候,


Nico

我第一次使用XSLT时也犯了同样的错误。您认为它是一种将开始和结束标记写入序列化XML输出文件的语言。这完全是错误的模型:它将节点写入树。写入节点是一个原子操作;不能将半个节点写入树。XSLT是格式良好的XML的要求反映了这一点;类似于
xsl:if
的操作包含一条创建元素节点的指令(该指令本身就是一个使用开始和结束标记编写的元素)
xsl:if
没有包含创建开始或结束标记的指令

这就要求对转型采取完全不同的思维方式。很难告诉您如何满足您的处理需求,因为我们只知道您试图实现的是完全错误的实现,并且很难从错误的代码中逆向工程需求

试着回答你的问题,解释你的输入看起来像什么,你想产生什么样的输出,以及(如果不明显的话)它们之间的关系。然后我们可以向您展示构建解决方案的正确方法。

谢谢Michael

我明白你的意思。的确,我刚刚接触XML/XSLT,现在正在开发Oracle框架实用工具。 输入如下(函数是框架的一部分):

Entity\u Text\u XML=''+'';
oXmlDoc.async=“false”;
loadXML(实体\文本\ XML);
tClickSearchResults=ProcessXsl(oXmlDoc,XmlFreeFile(../zElectrabelGAS\u GV/xslt/Click\u Search\u Result.xslt));
我尝试实现的是一个HTML输出,应该是:

<table>
    <tr> <!-- header row -->
        <td>
            <table>
                <tr>
                    <th>
                    ...
                    </th>
                </tr>
            </table>
        </td>
    </tr>
    <!-- here starts the issue, adding a row at the first record of a new period like month, quater and year -->
    <tr id="Month"> <!-- A new period started then a new row with table must be created. id value is filled by value like @Period -->
        <td>
            <table>
                <tr> <!-- Record 1 (one or more rows of period records) -->
                    <td>
                    ... 
                    </td>
                </tr>
                <tr> <!-- Record n -->
                    <td>
                    ... 
                    </td>
                </tr>
            </table>
        </td>
    </tr>

    <tr id="Quater"> <!-- A new period started then a new row with table must be created. id value is filled by value like @Period -->
        <td>
            <table>
                <tr> <!-- Record 1 (one or more rows of period records) -->
                    <td>
                    ... 
                    </td>
                </tr>
                <tr> <!-- Record n -->
                    <td>
                    ... 
                    </td>
                </tr>
            </table>
        </td>
    </tr>

    <tr id="Year"> <!-- A new period started then a new row with table must be created. id value is filled by value like @Period -->
        <td>
            <table>
                <tr> <!-- Record 1 (one or more rows of period records) -->
                    <td>
                    ... 
                    </td>
                </tr>
                <tr> <!-- Record n -->
                    <td>
                    ... 
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

...
... 
... 
... 
... 
... 
... 
XSLT必须是,因此您不能像试图做的那样有条件地单独包含/排除开始标记和结束标记。重新设计,使
xsl:if
(以及所有XSLT构造)的内容包含格式良好的XML。
<table>
    <tr> <!-- header row -->
        <td>
            <table>
                <tr>
                    <th>
                    ...
                    </th>
                </tr>
            </table>
        </td>
    </tr>
    <!-- here starts the issue, adding a row at the first record of a new period like month, quater and year -->
    <tr id="Month"> <!-- A new period started then a new row with table must be created. id value is filled by value like @Period -->
        <td>
            <table>
                <tr> <!-- Record 1 (one or more rows of period records) -->
                    <td>
                    ... 
                    </td>
                </tr>
                <tr> <!-- Record n -->
                    <td>
                    ... 
                    </td>
                </tr>
            </table>
        </td>
    </tr>

    <tr id="Quater"> <!-- A new period started then a new row with table must be created. id value is filled by value like @Period -->
        <td>
            <table>
                <tr> <!-- Record 1 (one or more rows of period records) -->
                    <td>
                    ... 
                    </td>
                </tr>
                <tr> <!-- Record n -->
                    <td>
                    ... 
                    </td>
                </tr>
            </table>
        </td>
    </tr>

    <tr id="Year"> <!-- A new period started then a new row with table must be created. id value is filled by value like @Period -->
        <td>
            <table>
                <tr> <!-- Record 1 (one or more rows of period records) -->
                    <td>
                    ... 
                    </td>
                </tr>
                <tr> <!-- Record n -->
                    <td>
                    ... 
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>