Note that there are some explanatory texts on larger screens.

plurals
  1. POXSLT - how to parse xml with recursive elements to Eclipse toc.xml?
    primarykey
    data
    text
    <p>I have the following XML:</p> <pre><code>&lt;HTML&gt; &lt;HEAD&gt; &lt;META name="GENERATOR" content="Microsoft HTML Help Workshop 4.1" /&gt; &lt;!-- Sitemap 1.0 --&gt; &lt;/HEAD&gt; &lt;BODY&gt; &lt;OBJECT type="text/site properties"&gt; &lt;param name="FrameName" value="contents" /&gt; &lt;/OBJECT&gt; &lt;UL&gt; &lt;LI&gt; &lt;OBJECT type="text/sitemap"&gt; &lt;param name="Name" value="Title1" /&gt; &lt;param name="Local" value="Ref1" /&gt; &lt;/OBJECT&gt; &lt;UL&gt; &lt;LI&gt; &lt;OBJECT type="text/sitemap"&gt; &lt;param name="Name" value="Title 2" /&gt; &lt;param name="Local" value="Ref2" /&gt; &lt;/OBJECT&gt; &lt;UL&gt; &lt;LI&gt; &lt;OBJECT type="text/sitemap"&gt; &lt;param name="Name" value="Title3" /&gt; &lt;param name="Local" value="Ref3" /&gt; &lt;/OBJECT&gt; &lt;/LI&gt; &lt;LI&gt; &lt;OBJECT type="text/sitemap"&gt; &lt;param name="Name" value="Title4" /&gt; &lt;param name="Local" value="Ref4" /&gt; &lt;/OBJECT&gt; &lt;/LI&gt; &lt;/UL&gt; &lt;/LI&gt; &lt;LI&gt; &lt;OBJECT type="text/sitemap"&gt; &lt;param name="Name" value="Title5" /&gt; &lt;param name="Local" value="Ref5" /&gt; &lt;/OBJECT&gt; &lt;/LI&gt; &lt;/UL&gt; &lt;/LI&gt; &lt;LI&gt; &lt;OBJECT type="text/sitemap"&gt; &lt;param name="Name" value="Title6" /&gt; &lt;param name="Local" value="Ref6" /&gt; &lt;/OBJECT&gt; &lt;/LI&gt; &lt;/UL&gt; &lt;/BODY&gt; &lt;/HTML&gt; </code></pre> <p>I need to transform it to an "Eclipse Help" format <code>toc.xml</code> file, like this:</p> <pre><code>&lt;toc label="Sample Table of Contents"&gt; &lt;topic label="Title1" href="Ref1"&gt; &lt;topic label="Title2" href="Ref2"&gt; &lt;topic label="Title3" href="Ref3"/&gt; &lt;topic label="Title4" href="Ref4"/&gt; &lt;/topic&gt; &lt;topic label="Title5" href="Ref5"&gt; &lt;/topic&gt; &lt;/topic&gt; &lt;topic label="Title6" href="Ref6"/&gt; &lt;/toc&gt; </code></pre> <p>I tried to create the following XSLT, which didn't work:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;?altova_samplexml D:\Documents and Settings\oshecht\Desktop\XSL\Copy of toc.xml?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" &gt; &lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" /&gt; &lt;xsl:template match="/"&gt; &lt;toc&gt; &lt;xsl:apply-templates select="//LI" /&gt; &lt;/toc&gt; &lt;/xsl:template&gt; &lt;xsl:template match="//LI"&gt; &lt;topic&gt; &lt;xsl:apply-templates select="OBJECT/param" mode="val" /&gt; &lt;xsl:apply-templates select="OBJECT/param" mode="ref" /&gt; &lt;xsl:apply-templates select="/UL/LI" /&gt; &lt;!--xsl:apply-templates select="//UL//LI" mode="subelement" /--&gt; &lt;/topic&gt; &lt;/xsl:template&gt; &lt;xsl:template match="OBJECT/param" mode="val"&gt; &lt;xsl:if test="@name = 'Name'"&gt; &lt;xsl:attribute name="label"&gt; &lt;xsl:value-of select="@value" /&gt; &lt;/xsl:attribute&gt; &lt;/xsl:if&gt; &lt;/xsl:template&gt; &lt;xsl:template match="OBJECT/param" mode="ref"&gt; &lt;xsl:if test="@name = 'Local'"&gt; &lt;xsl:attribute name="href"&gt; &lt;xsl:value-of select="@value" /&gt; &lt;/xsl:attribute&gt; &lt;/xsl:if&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>Can you please advise?</p> <p>Thanks:)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload