XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Manish DheliaSubject: how to remove the XML elements dynamically
Author: Manish Dhelia
Date: 28 Mar 2007 03:40 AM
Following is my XML data:

<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="movies.xsl"?>
<ul>
<li type="square">Screen</li> <br/>
<li>
<ul>
<li>sub bullet</li>
</ul>
</li>
</ul>

Problem:How can I remove the second "li" tag dynamically using XSLT in the above XML data keeping the other tags under it intact.

and following is my XSLT file saved as movies.xsl that I'm working on:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">


<xsl:variable name="var" select="//movies/movie/name"/>


<xsl:for-each select="//ul">
<xsl:apply-templates select="li" />
</xsl:for-each>



</xsl:template>
<xsl:template match="strong|p|u|em|ul|li|b|br|h1|h2|h3|h4|h5|h6|hr|i|ol|q|s|sub|sup|small|table|tr|td|thead|tfoot|th|tbody|big|tt|span|blockquote">
<xsl:element name="{name()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

Please reply with the solution.

Posttop
(Deleted User) Subject: how to remove the XML elements dynamically
Author: (Deleted User)
Date: 30 Mar 2007 08:02 AM
Hi Manish,
if your reference to the "second 'li'" node has to be interpreted as "the 'li' node that is nested inside another 'li' node" you can try:
- adding a mode to the copier template
- removing 'li' from the list of matches for that template
- propagating the mode to the apply-templates
- creating a new template processing just the 'li' node with a mode=1 that will not create the element, but just invoke apply-templates
- creating a new template processing just the 'li' node with a mode=0 that will create the element, and then invoke apply-templates with mode=1

Hope this helps,
Alberto

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.