[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Design problem - print header information only if
Hi Ming-tzung, Try this: <xsl:template match="Header"> <xsl:if test="contains(Detail, 'sometext')"> <xsl:apply-templates/> </xsl:if> </xsl:template> Where 'sometext' is the text match for your satisfaction criteria. Zarella > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Dung, > Ming-tzung > Sent: Wednesday, April 24, 2002 12:37 PM > To: XSLT List (E-mail) > Subject: Design problem - print header information only if some > element exists in the detail. > > > 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 > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|