[xsl] Design problem - print header information only if some element ex ists in the detail.

Subject: [xsl] Design problem - print header information only if some element ex ists in the detail.
From: "Dung, Ming-tzung" <Ming-tzung_Dung@xxxxxxxxxxxxx>
Date: Wed, 24 Apr 2002 11:37:12 -0600
Hi, 
   I have an input XML source as the following:
....
<Header>
....
<!-- could have multiple detail information. -->
<Detail>..<Detail>
</Header>
    I need to output the content of the Header ONLY IF certain information
exists in the detail. (Let us called this as the satisfied Detail). Besides,
each satisfied Detail needed to print out after the Header. The design
forces also includes that the testing condition may grow complex in the
future.
I guess that I have two ways in solving this; however, none of the solution
I come up with is not a good solution.
<1>
  Pass the document to one XSL for filtering out the 'unsatisfied' Detail.
Then pass the filtered XML to the XSLT again for  output. 
  ==>Disadvantage - the performance.
<2> 
   Use <xsl:for-each > to select the satisfied Detail node.
   ==>Disadvantage: If the condition grows complex, I am not sure whether
the select attribute within the <xsl:for-each> can fulfill the needs. In
addition, If there are multiple detail, how I can print the Detail element
once only within the <xsl:for-each> body? (The only solution for this I can
see is have two <xsl:for-each>. The first one is check there is any Detail
satisfied. If yes, print the header information. Then the second print out
the detail. )

  Thanks in advance!!
             

Ming-tzung Dung


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


Current Thread