Subject: Re: [xsl] creating top-level elements from within child elements From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 22 Feb 2005 15:36:41 GMT |
The problem Im facing with this approach is that I do not want A2 to appear i n the output xml file unless some condition in the A1 template is true. This brings me back to the use of a 'flag' boolean variable which will check whether its value is 'true' before creating A2. If the test affects the generation of both A1 and A2 the just move it up to the point that you are generating those elements instead of having it in the template that's just generating A2. really there is no problem here. However it would be much more efficient to have some feature in XSLT which will allow you to position an element outside the template. templates are the XSLT mechanism for determing where in the result tree constructed elements are placed. So I have no idea what you mean here. > I am not sure how you can create the element <SubConcepts> from within > the <PrimeConcept> template match. My present code is this is just the same as generating any other element. You (still) have <xsl:template match="/"> <Top> <PrimeConcept><xsl:apply-templates select="Top/TopNode" mode="top"/></PrimeConcept> </Top> </xsl:template> which is explictly wrapping a PrimeConcept around everything, which is why everything is coming out as a child of PrimeConcept. You didn't post your input, so this isn't filled in , but you want something like: <xsl:template match="Top"> <Top> <xsl:apply-templates select="TopNode" /> </Top> </xsl:template> <xsl:template match="TopNode"> <PrimeConcept id='10180'>Car</PrimeConcept> <SubConcepts> <SubConcept id='10298'>Toyota</SubConcept> </SubConcepts> </xsl:template> will do the job, but presumably you want to replace some of those fixed element and attribute names by xpath expressions. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] creating top-level elemen, RQamar | Thread | Re: [xsl] creating top-level elemen, RQamar |
RE: [xsl] using an attribute's valu, Matthieu Ricaud | Date | Re: [xsl] xslt and the filesystem, Daniel Bibbens |
Month |