0

I want to add coditional a table, but I get the error "Error (0x80004005): The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document."

What I want is this:

<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 -->

The goal of this is that I can hide with jQuery a row " <tr id="$ClickPeriod">", so that the table within this row is also hidden.

Maybe it is also possible wit a div, but there is also a table header row. Independent of this table header, It must possible to hide the different rows in the subtables. The reason that I try this way is, that it is a part of a framework. All kind of css is already defined. And I know tables are old fashioned but it is not web application for the world.

Can somenone help me out with this? I'm not a guru on XSLT/XSD area!

Regards,

Nico

Daniel Corzo
  • 1,055
  • 2
  • 19
  • 32
user2363969
  • 105
  • 1
  • 10
  • XSLT must be [***well-formed***](http://stackoverflow.com/a/25830482/290085), so you cannot conditionally include/exclude start tags and end tags independently as you're trying to do. Rework your design such that the contents of `xsl:if` (and all XSLT constructs) contain well-formed XML. – kjhughes Dec 17 '15 at 17:11

2 Answers2

0

I made the same mistake when I first started with XSLT. You are thinking of it as a language that writes start and end tags to a serialized XML output file. That's quite the wrong model: it writes nodes to a tree. Writing a node is an atomic operation; you can't write half a node to a tree. The requirement that XSLT is well-formed XML reflects this; an operation like xsl:if encloses an instruction that creates an element node (and this instruction is itself an element written with a start and end tag); xsl:if doesn't enclose instructions that create start or end tags.

This demands a radically different way of thinking about the transformation. It's very difficult to tell you how to meet your processing requirements, because the only thing we know about what you are trying to achieve is from a completely wrong implementation, and it's hard to reverse-engineer requirements from incorrect code.

Try to repost your question explaining what your input looks like, what output you want to produce, and (if it isn't obvious) how they relate to each other. Then we can show you the right way to structure the solution.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
0

Thanks Michael,

I understand what you mean. And it is true that I'm quit new to XML/XSLT and I'm working on framework Oracle Utilities. The input is like this (the functions are part of framework):

Entity_Text_XML = '<CLICK_SEARCH_RESULT>'+'<ENTITY' + records of data which are used in the XSLT + ' /></CLICK_SEARCH_RESULT>';
oXmlDoc.async = "false";
oXmlDoc.loadXML(Entity_Text_XML);

tClickSearchResults   = ProcessXsl(oXmlDoc, XmlFreeFile("../zElectrabelGAS_GV/xslt/Click_Search_Result.xslt"));

What I try to achieve is a HTML output that should be:

<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>
user2363969
  • 105
  • 1
  • 10