[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Another newbie question

Subject: Re: Another newbie question
From: "S.Ramaswamy" <srswamy@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 09 Dec 1999 10:15:28 +0530
ancestor forms
Sanjay Saxena wrote:
> 
> 
> Thanks a lot. However, this does not work. As suggested, CONTAINERS
> is not my root. My XML looks as shown below:
> 
> <FORMS>
>     <CONTAINERS>
>         <CONTAINER>
>             <PRE_HTML>DEPT_PREHTML</PRE_HTML>
>             <TITLE>Departments</TITLE>
>             <POST_HTML>DEPT_POSTHTML</POST_HTML>
>         </CONTAINER>
> 
>         <CONTAINER>
>             <PRE_HTML>EMP_PREHTML</PRE_HTML>
>             <TITLE>Employees</TITLE>
>             <POST_HTML>EMP_POSTHTML</POST_HTML>
>         </CONTAINER>
>     </CONTAINERS>
> 
>     <DEPT_PREHTML>
>         <!-- Well-formed HTML. -->
>         <DIV id="Layer1" style="position: absolute">
>             <IMG src="/images/edu.gif" width="917"
>                  height="104"/>
>         </DIV>
>     </DEPT_PREHTML>
> 
>     <DEPT_POSTHTML>
>         <!-- Some more well-formed HTML. -->
>     </DEPT_POSTHTML>
> 
>     <EMP_PREHTML>
>         <!-- Some more well-formed HTML. -->
>     </EMP_PREHTML>
> 
>     <EMP_POSTHTML>
>         <!-- Some more well-formed HTML. -->
>     </EMP_POSTHTML>
> </FORMS>
> 
> I tried to use the complete path /FORMS/DEPT_PREHTML and
> /FORMS/DEPT_POSTHTML
> as values for PRE_HTML and POST_HTML elements, respectively. It still
> does
> not work. The XSL stylesheet looks as shown below:
> 
> <xsl:template match="/FORMS/CONTAINERS">
>     <xsl:for-each select="CONTAINER">
> 
>         <xsl:copy-of select="//*[name(.)=current()/PRE_HTML]" />

   //* means any element that is a descendant of CONTAINER  
   whereas DEPT_PREHTML is a descendant of FORMS so 
   <xsl:copy-of select="ancestor::FORMS//*[name(.)=current()/PRE_HTML"
   ancestor::FORMS              select the element named FORMS which is
an ancestor of current node CONTAINER
   //                           select the descendants of FORMS
   [name(.)=current()/PRE_HTML] apply a filter on descendants such that
only the element whose tag
                                is equal to the current node's child
PRE_HTML is copied

  
> 
>         <!-- Do some more things here -->
> 
>         <xsl:copy-of select="//*[name(.)=current()/POST_HTML]" />
> 
>     </xsl:for-each>
> </xsl:template>
> 
> I tried using xsl:variable as suggested by another post and that did
> not work either. I am not seeing the node containing the well-formed
> HTML getting copied to the output.
> 
> Thanks again,
> -- Sanjay
> 
> David Carlisle wrote:
> 
> >      <xsl:template match="/CONTAINERS">
> > This only works if CONTAINERS is the document element but  you
> > indicated
> > I think that your DEPT_POSTHTML elements were outside this.
> >
> >         <xsl:copy-of select="PRE_HTML"
> >             <xsl:apply-templates select="*|@*|text()"/>
> >         </xsl:copy-of>
> >
> > you are confusing the syntax for xsl:copy and xsl:copy-f. and also
> > that select expression starts from the current CONTAINER node, but
> > PRE_HTML isn't a child of that.
> >
> > So....
> >
> > ===========================================
> > <x>
> > <CONTAINERS>
> >     <CONTAINER>
> >         <PRE_HTML>DEPT_PREHTML</PRE_HTML>
> >         <TITLE>Departments</TITLE>
> >         <POST_HTML>DEPT_POSTHTML</POST_HTML>
> >     </CONTAINER>
> >     <CONTAINER>
> >         <PRE_HTML>EMP_PREHTML</PRE_HTML>
> >         <TITLE>Employees</TITLE>
> >         <POST_HTML>EMP_POSTHTML</POST_HTML>
> >     </CONTAINER>
> > </CONTAINERS>
> >
> > <DEPT_PREHTML>
> >     <DIV id="Layer1" style="position: absolute">
> >         <IMG src="/images/edu.gif" width="917"
> > height="104"/>
> >     </DIV>
> > </DEPT_PREHTML>
> >
> > <DEPT_POSTHTML>
> >      <!-- Some more well formed HTML. -->kkk
> > </DEPT_POSTHTML>
> >
> > </x>
> >
> > ===========================================
> >
> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> >                 version="1.0"
> >                 >
> >
> > <xsl:output method="xml" indent="yes"/>
> >
> > <xsl:template match="CONTAINERS">pppp
> >     <xsl:for-each select="CONTAINER">l
> >
> >         <xsl:copy-of select="//*[name(.)=current()/PRE_HTML]" />
> >
> >         <!-- Do some more things here -->
> >
> >         <xsl:copy-of select="//*[name(.)=current()/POST_HTML]" />
> >
> >     </xsl:for-each>
> > </xsl:template>
> >
> > </xsl:stylesheet>
> >
> > ===========================================
> >
> > David
> > PS you see it is better to ask on the list, than to ask directly:-)
> >
> > PPS You mail was included twice, once as text and once a HTML,
> > please
> > don't do that.
> >
> >  XSL-List info and archive:
> > http://www.mulberrytech.com/xsl/xsl-list

-- 
==--==--==--==--==--==--==--==--==--==--==--==--==--==
S.Ramaswamy
Matrix Infotech Syndicate
D-7, Poorti, Vikaspuri, New Delhi, 110018, India
PHONE:    +91-11-5610050,   FAX: +91-11-5535103  
WEB         http://MatrixInfotech.HyperMart.Net
==--==--==--==--==--==--==--==--==--==--==--==--==--==


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.