Subject: Re: Another newbie question From: "S.Ramaswamy" <srswamy@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 08 Dec 1999 10:15:01 +0530 |
Sanjay Saxena wrote: > > Hi, > > I am a newbie so please bear with me. In my XML, I have > meta-data which references data. For example, my XML looks > as shown: > > <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> > > So, every container has a PRE_HTML and POST_HTML element > which references other nodes in my XML. For example, the > Departments container references the DEPT_PREHTML and > DEPT_POSTHTML nodes. The DEPT_PREHTML and DEPT_POSTHMTL > nodes look as shown: > > <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. --> > </DEPT_POSTHTML> > > Similarly, EMP_PREHTML and EMP_POSTHTML contain well-formed > HTML. > > In my XSL, I would like to iterate through each of the > containers and spit out the well-formed HTML which is sitting in > the respective PRE_HTML and POST_HTML nodes. However, I am > not having any luck dereferencing the node name that is the > value of an element. In the XSL, I am using the xsl:copy-of > to spit out the node specified by the PRE_HTML and POST_HTML > elements of the CONTAINER. But, this does not work. The XSL > looks as shown below: > > <xsl:template match="/CONTAINERS"> > <xsl:for-each select="CONTAINER"> > > <xsl:copy-of select="PRE_HTML" > <xsl:apply-templates select="*|@*|text()"/> > </xsl:copy-of> Well <xsl:copy-of puts the complete node element (PRE_HTML and its text) into the output tree. But right now PRE_HTML is child under CONTAINER. What you need find out children of an element somwehere else in the document whose name is contained within this PRE_HTML. Step 1: get the text() associated with PRE_HTML <xsl:variable name="preHTML" select="PRE_HTML" /> Step2 : search for an element whose name is equal to preHTML starting from the document root and copy its child element. <xsl:copy-of select="/*[name() = $preHTML]/*"> > > <!-- Do some more things here --> > > <xsl:copy-of select="POST_HTML" > <xsl:apply-templates select="*|@*|text()"/> > </xsl:copy-of> > > </xsl:for-each> > </xsl:template> > > Can somebody shed any light on this? How do I spit out > the well-formed HTML sitting in various nodes that are > referenced by the PRE_HTML and POST_HTML elements? > > > Thanks in advance, > Sanjay ==--==--==--==--==--==--==--==--==--==--==--==--==--== 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Another newbie question, Sanjay Saxena | Thread | Re: Another newbie question, David Carlisle |
Re: Serialize DOM, S.Ramaswamy | Date | Re: Standardizing HTML look-and-fee, S.Ramaswamy |
Month |