xsl-list
[Top] [All Lists]

RE: #Please Help: Nested conditions

2004-02-20 14:18:47
Thank you, Ken, also for your patient explanations to a newbie who
hasn't yet grasped fully the philosophy which is behind the XSL lexic
and grammar. I'll come to it later.

1st, your XSL snippet does not work out; the output is:
                <TABLE>
                        <TTITLE/>
                        <TBODY/>
                </TABLE>
I accept your gentle offer and attach the code of the input (an XML
export from a non-XML Adobe FrameMaker file) and the XSLT file to this
mail (see below).

2nd, let me come to your comments, the purpose of which, I guess, was to
make me understand once and for all. So let me try:

<Q>    <xsl:template match="TABLE">
<Q>      <TABLE>
<Q>          ...
<Q>         <xsl:if test="TROW/TH">
You are looking here for all <TH> that are children of a <TROW>;
however, if I know that all <TH> will always be in a <TROW>, I could
write also <xsl:if test="TH">, couldn't I? Or would this imply here that
I would be looking for <TH> that are children of <TABLE>?


<Q>             <xsl:apply-templates select="TROW[TH]"/>
A similar expression I have found in M. Kay's "XSLT P.R.2" at the item
"PredicateExpr". This is not where I would have looked for it, simply
because I've never heard the term "PredicateExpr"...


<Q>       <xsl:copy><xsl:apply-templates/></xsl:copy>
I would have written:
                <TROW><xsl:apply-templates/></TROW>
but I assume it would have been the same. Correct?


<Q> >                 <xsl:text disable-output-escaping="yes">
<Q> >                         &#60;&#47;TGROUP&#62;</xsl:text>
<Q> The above is expressly *not* the purpose of
<Q> disable-output-escaping= ...
I have used it as well to produce the DOCTYPE -- would that be ok?


<Q> A number of things that I have hopefully illustrated for you above.
Once again, thank you,

- Matthias


============================================
Attachments
============================================

---------------------------------
1) Input file
---------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"
href="D:\Daten\NEXUS\XML_FMaker\XSLT\NEXUS_XWare.xsl"?>
<XML>
        <TITLE/>
        <H1-H1>
                <A ID="pgfId-492742"/>Descrizione funzionale</H1-H1>
        <H2-H2>
                <A ID="pgfId-507147"/>Uso previsto</H2-H2>
        <A2-INSET-Source>
                <A ID="pgfId-647166"/>Uso previsto della macchina descritta nel
presente manuale di istruzioni e la depurazione delle acque di scarico
urbane e/o industriali.</A2-INSET-Source>
        <TABLE>
                <CAPTION>
                        <Table-TITLE>
                                <A ID="pgfId-647169"/>
Processi di depurazione</Table-TITLE>
                </CAPTION>
                <ROW>
                        <TH ROWSPAN="1" COLSPAN="1">
                                <Table-HEADING>
                                        <A ID="pgfId-647171"/>
Processi/sostanze</Table-HEADING>
                        </TH>
                </ROW>
                <ROW>
                        <CELL ROWSPAN="1" COLSPAN="1">
                                <Table-PARA>
                                        <A ID="pgfId-647173"/>
Concentrazione di fanghi, sabbia od altri solidi in sospensione delle
acque</Table-PARA>
                        </CELL>
                </ROW>
                <ROW>
                        <CELL ROWSPAN="1" COLSPAN="1">
                                <Table-PARA>
                                        <A ID="pgfId-647175"/>
Concentrazione di sabbie od altri solidi granulosi in sospensione nell'
acqua</Table-PARA>
                        </CELL>
                </ROW>
                <ROW>
                        <CELL ROWSPAN="1" COLSPAN="1">
                                <T2-Table-PARA>
                                        <A ID="pgfId-647177"/>
Separazione di solidi grossolani trascinati da una corrente d'
acqua</T2-Table-PARA>
                        </CELL>
                </ROW>
                <ROW>
                        <CELL ROWSPAN="1" COLSPAN="1">
                                <Table-PARA>
                                        <A ID="pgfId-647179"/>
Raccolta dei surnatanti presenti sulla superficie delle
acque</Table-PARA>
                        </CELL>
                </ROW>
                <ROW>
                        <CELL ROWSPAN="1" COLSPAN="1">
                                <Table-PARA>
                                        <A ID="pgfId-647181"/>
Espulsione dei gas o vapori in sospensione nelle acque</Table-PARA>
                        </CELL>
                </ROW>
        </TABLE>
</XML>

---------------------------------
2) XSL
---------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

        <xsl:template match="XML">
                <xsl:text disable-output-escaping="yes">&#60;&#33;DOCTYPE NEXUS 
SYSTEM
&#34;D&#58;&#92;Daten&#92;NEXUS&#92;XML&#95;FMaker&#92;DTDs&#92;NEXUS&#9
5;XWare&#46;dtd&#34;&#62;
</xsl:text>

                <NEXUS>
                        <HEAD>
                                <META title="" category="" product="" 
company="" project=""
version="" author="" translator="" mod-by="" mod-date="" state=""
language="" keywords="" copyright="" doc-no=""/>
                        </HEAD>
                        <BODY>
                                <xsl:apply-templates/>
                        </BODY>
                </NEXUS>
        </xsl:template>

        <xsl:template match="H1-H1">
                <H type="h-1">
                        <xsl:value-of select="."/>
                </H>
        </xsl:template>
        <xsl:template match="H2-H2">
                <H type="h-2">
                        <xsl:value-of select="."/>
                </H>
        </xsl:template>

        <!--    INSETs shall be boxed later on   -->
        <xsl:template match="A2-INSET-Source">
                <P type="p-10">
                        <xsl:value-of select="."/>
                </P>
        </xsl:template>

        <xsl:template match="TABLE">
                <TABLE>
                        <TTITLE>
                                <xsl:value-of select="Table-TITLE"/>
                        </TTITLE>
                <xsl:if test="TROW/TH">
                        <THEAD>
                                <xsl:apply-templates select="TROW[TH]"/>
                        </THEAD>
                </xsl:if>
                <xsl:if test="TROW/TF">
                        <TFOOT>
                                <xsl:apply-templates select="TROW[TF]"/>
                        </TFOOT>
                </xsl:if>
                        <TBODY>
                                <xsl:apply-templates select="TROW[CELL]"/>
                        </TBODY>
                </TABLE>
        </xsl:template>

        <xsl:template match="TROW">
                <xsl:copy><xsl:apply-templates/></xsl:copy>
        </xsl:template>

        <xsl:template match="TH | CELL | TF">
                <TDATA>
                        <xsl:apply-templates/>
                </TDATA>
        </xsl:template>

</xsl:stylesheet>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>