[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Up-conversion using XSLT 1.0
Hi list, It seems not to be too difficult to get the element "zitat" only once with XSLT 2.0, but I've still no idea how to do it with XSLT 1.0. Can anyone help? Regards, Manfred Staudinger, Vienna 2005/10/17, Manfred Staudinger <manfred.staudinger@xxxxxxxxx>: > Hi list, > its not exactly an up-conversion, because the input docs should stay > with a minimum of mark-up and I'm currently in the process to define > that minimal set. The aim of the transformations then is to provide the > docs temporarily in a form suitable to a program, in this case a browser. > - Anyway, I've the following input: > > <?xml version="1.0" encoding="UTF-8"?> > <?xml-stylesheet href="../view-list.xsl" type="text/xsl"?> > <doc> > text-1 > text-1 > <div class="index"> > elements in div > </div> > text-2 > text-2 > <ul> > text in ul > text in ul > </ul> > text-3-1 > text-3-2 > text-3-3 > text-4-1 > text-4-2 > </doc> > There can be 0-10 ul-elements anywhere between > text-2 and text-3. The lines "text in ul" are processed > by using a named template (not shown here). > > With the stylesheet > <?xml version="1.0" encoding="UTF-8" ?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:output method="xml" indent="yes" /> > <xsl:variable name="LF" select="'
'" /> > <xsl:template match="doc"> > <xsl:apply-templates select="node()|@*" /> > </xsl:template> > <xsl:template match="text()"> > <xsl:call-template name="insert-list"> > <xsl:with-param name="list" select="." /> > </xsl:call-template> > </xsl:template> > <xsl:template match="doc/div[@class='index']"> > <xsl:copy-of select="." /> > </xsl:template> > <xsl:template match="doc/ul"> > <ul><xsl:value-of select="."/></ul> > </xsl:template> > > <xsl:template match="/"> > <body> > <xsl:value-of select="$LF" /> > <xsl:apply-templates select="node()|@*" /> > </body> > </xsl:template> > > <xsl:template name="insert-list"> > <xsl:param name="list"/> > <xsl:param name="list2" select="''"/> > <xsl:variable name="line" select="substring-before($list, $LF)"/> > <xsl:choose> > <xsl:when test="starts-with($line,' ')"> > <xsl:call-template name="insert-list"> > <xsl:with-param name="list" select="substring-after($list, $LF)" /> > <xsl:with-param name="list2" select="concat($list2, > substring($line, 4), $LF)" /> > </xsl:call-template> > </xsl:when> > <xsl:when test="string-length($list2)>0"> > <zitat> > <xsl:value-of select="$LF" /> > <xsl:call-template name="insert-list"> > <xsl:with-param name="list" select="$list2"/> > </xsl:call-template> > </zitat> > <xsl:value-of select="$LF" /> > <xsl:call-template name="insert-list"> > <xsl:with-param name="list" select="$list"/> > </xsl:call-template> > </xsl:when> > <xsl:when test="string-length($list)=0"> > </xsl:when> > <xsl:otherwise> > <xsl:if test="string-length($line)>0"> > <xsl:value-of select="concat('+',$line,$LF)" /> > </xsl:if> > <xsl:call-template name="insert-list"> > <xsl:with-param name="list" select="substring-after($list, $LF)" /> > <xsl:with-param name="list2" select="$list2"/> > </xsl:call-template> > </xsl:otherwise> > </xsl:choose> > </xsl:template> > </xsl:stylesheet> > > I get the following output: > <?xml version="1.0" encoding="utf-8"?> > <body> > +text-1 > +text-1 > <div class="index"> > elements in div > </div> > <zitat> > +text-2 > +text-2 > </zitat> > > <ul> > text in ul > text in ul > </ul> > <zitat> > +text-3-1 > +text-3-2 > +text-3-3 > </zitat> > +text-4-1 > +text-4-2 > </body> > > > This is what I would like to get, but I've no idea how to do: > <?xml version="1.0" encoding="utf-8"?> > <body> > +text-1 > +text-1 > <div class="index"> > elements in div > </div> > <zitat> > +text-2 > +text-2 > <ul> > text in ul > text in ul > </ul> > +text-3-1 > +text-3-2 > +text-3-3 > </zitat> > +text-4-1 > +text-4-2 > </body> > > Any comments will be appreciated. > Regards, Manfred Staudinger, Vienna
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|