This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: problem with xsl:choose


At 02:19 25-05-2001, Student1 ASCO-ELK (RBJE/ELK) wrote:
>unfortunately i have some book about xlst ;)
>
>my xml file
><data>
>   <screen h=2 w=3 />
>....
>   <table h=2 w=4 />
>....
></data>
>
>sorry, i forget to mention that, the <screen> and <table> are NOT mandatory.
>the xmldocument varies
>and if for example the <table> tag is not in the document i dont want the
><table name='table'> to be in the final document.

Use templates.

<xsl:template match="/">
   <xsl:if test="not(//screen) and not(//table)">
     <xsl:message>error</xsl:message>
   </xsl:if>
   <xsl:apply-templates select="//screen|//table"/>
</xsl:template>

<xsl:template match="screen">
   <table class=screen>
     <xsl:attribute name=tID>
       <xsl:value-of select="@h"/>
     <xsl:attribute>
     <xsl:call-template name='screenHdr'/>
     <!-- put whatever is in your current screen template here -->
   </table>
</xsl:template>

<xsl:template match="table">
   <table class=table>
     <xsl:attribute name=tID>
       <xsl:value-of select="@h"/>
     <xsl:attribute>
     <xsl:call-template name='tableHdr'/>
     <!-- put whatever is in your current table template here -->
   </table>
</xsl:template>

>i cant use only the <xsl:apply-templates ... /> because i dont want the
><table ...></table> to appear in the outputfile
>
>you know now what i mean ?

Sorry, no.  Your example, if it worked, would put table tags in the output 
file; if you don't want them, don't generate them in your stylesheet.

-Chris
-- 
Christopher R. Maden, XML Consultant
DTDs/schemas - conversion - ebooks - publishing - Web - B2B - training
<URL: http://crism.maden.org/consulting/ >
PGP Fingerprint: BBA6 4085 DED0 E176 D6D4  5DFC AC52 F825 AFEC 58DA


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]