![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - XHTML changing >Thread Next - Re: XHTML changing Re: XHTML changingTo: NULL Date: 9/1/2007 9:17:00 AM "Philipp Kraus" <philipp.kraus@f...> wrote in message news:fba6ns$tp4$1@o...... > Hello, > > I hope my question isn't off topic. > I have a XHTML file (offline webpage) and now I change some HTML > struktures with a XSLT. > I create my XSLT file and in my first step I will copy all HTML tags and > one tag should be cleared. > I have build my XSLT with a editor like this way: > > <xsl:template match="sem"> > <xsl:text>\section{</xsl:text> > <xsl:value-of select="@value"/> > <xsl:text>}</xsl:text> > <xsl:apply-templates /> > </xsl:template> > <xsl:template match="name"> > <xsl:text>\subsection{</xsl:text> > <xsl:value-of select="@value"/> > <xsl:text>}</xsl:text> > <xsl:apply-templates /> > </xsl:template> > > In my HTML Struktur I have this path: html/body/div (@aussen) / hr (@hide) > / div (@page) / hr (@hide) / div (@navi) (all @ are attributes). It's also > a typo3 strukture. I would like to clear everything on the node "div > (@navi)" and all childs down of the node. All other HTML Tags should be > copy in a new HTML. > Is this the right way? > > <xsl:template match="path_to_div_navi"> > checking attribute named "navi" > no -> <xsl:apply-templates /> > yes -> nothing > </xsl:template> > <xsl:template match="*"> > how I copy a node with full data? > </xsl:template> > > Thanks a lot > > Phil > > Phil Two things: 1) If your file is XHTML then you'll need to include the XHTML namespace declaration and your XPath should include the associated prefix: xhtml:html/xhtml:body/... etc. 2) If you just intend to copy all but a specific part then the standard practice is to use the identity transform with template overrides for elements that you don't need. For example to copy all but div elements with a class attribute of hide and their children then use: <!-- The Identity Transformation --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Whenever you find any node or any attribute --> <xsl:template match="node()|@*"> <!-- Copy the current node --> <xsl:copy> <!-- Including any attributes it has and any child nodes --> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <!-- Overrides here --> <xsl:template match="div[@class='hide']/> </xsl:stylesheet> (I've not included the namespace stuff here, check http://www.dpawson.co.uk/xsl/sect2/N5536.html numbers 13 and 23 for more info.) -- Joe Fawcett (MVP - XML) http://joe.fawcett.name | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||
|
