Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your input document was so full of formation errors, I've had to take the risk of guessing your intentions. Please see the transform solution below. I deliberately did not include the insertion of the table elements around your comment "ADD TABLE/TR/TD TAG", as this section seemed so nutty that any solution that I provided for you here would likely be a wrong interpretation of your required rules of transformation.</p> <p><strong>This XSLT 1.0 style-sheet ...</strong></p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="xhtml"&gt; &lt;xsl:output method="xml" indent="yes" encoding="UTF-8"/&gt; &lt;xsl:strip-space elements="*" /&gt; &lt;xsl:template match="@*|node()"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*|node()"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="xhtml:body"&gt; &lt;element add="xyz" id="23" /&gt; &lt;element add="xyz" id="24" /&gt; &lt;body onLoad="ada" bgcolor="pink"&gt; &lt;xsl:apply-templates select="@*|node()"/&gt; &lt;/body&gt; &lt;/xsl:template&gt; &lt;xsl:template match="xhtml:element1[@name='abc']/@src"&gt; &lt;xsl:attribute name="src"&gt;xyz.jpg&lt;/xsl:attribute&gt; &lt;/xsl:template&gt; &lt;xsl:template match="xhtml:input[@id='1']"&gt; &lt;form name="form"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*|node()"/&gt; &lt;/xsl:copy&gt; &lt;xsl:apply-templates select="following-sibling::xhtml:div[1]" mode="inside-form"/&gt; &lt;/form&gt; &lt;/xsl:template&gt; &lt;xsl:template match="xhtml:div[ preceding-sibling::xhtml:*[1] /self::xhtml:input[@id='1']]"/&gt; &lt;xsl:template match="xhtml:div" mode="inside-form"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*|node()"/&gt; &lt;/xsl:copy&gt; &lt;input type="submit" value="Done"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>... will take this input document ...</strong></p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="o"&gt; &lt;div id="nd"&gt; &lt;p&gt;1&lt;/p&gt; &lt;/div&gt; &lt;div class="TF" id="id12"&gt; &lt;element1 name="abc" src="abc.jpg"/&gt; &lt;input type="radio" id="1" event="xyz"/&gt; &lt;div class="q"&gt; &lt;br/&gt; &lt;div id="ta3" class="block"&gt; &lt;span style="a"&gt;ABC&lt;/span&gt; &lt;/div&gt; &lt;br/&gt;T &lt;input/&gt; F &lt;input/&gt; &lt;div id="sf"&gt; &lt;div id="ta3"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>...and yield this output document ...</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8" /&gt; &lt;/head&gt; &lt;element add="xyz" id="23" /&gt; &lt;element add="xyz" id="24" /&gt; &lt;body onLoad="ada" bgcolor="pink"&gt; &lt;div id="o"&gt; &lt;div id="nd"&gt; &lt;p&gt;1&lt;/p&gt; &lt;/div&gt; &lt;div class="TF" id="id12"&gt; &lt;element1 name="abc" src="xyz.jpg" /&gt; &lt;form name="form"&gt; &lt;input type="radio" id="1" event="xyz" /&gt; &lt;div class="q"&gt; &lt;br /&gt; &lt;div id="ta3" class="block"&gt; &lt;span style="a"&gt;ABC&lt;/span&gt; &lt;/div&gt; &lt;br /&gt;T &lt;input /&gt; F &lt;input /&gt;&lt;div id="sf"&gt;&lt;div id="ta3" /&gt;&lt;/div&gt;&lt;/div&gt; &lt;input type="submit" value="Done" /&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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