From 2e41368fb4ef9a2ab8aa3a4201c75eb0e6a96ad4 Mon Sep 17 00:00:00 2001 From: Martin Goik <goik@hdm-stuttgart.de> Date: Tue, 12 Apr 2016 13:42:06 +0200 Subject: [PATCH] Adding identity transformation hint for generic xml --> html visualization script. --- Doc/Sda1/xslt.xml | 64 ++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/Doc/Sda1/xslt.xml b/Doc/Sda1/xslt.xml index dbbfcf17a..a101f7f4c 100644 --- a/Doc/Sda1/xslt.xml +++ b/Doc/Sda1/xslt.xml @@ -331,12 +331,13 @@ Martin Goik</computeroutput></programlisting> </section> <section xml:id="xpath"> - <title><link xlink:href="https://www.w3.org/TR/xpath">XPath</link> and node - sets</title> + <title><link xlink:href="https://www.w3.org/TR/xpath">XPath</link> and + node sets</title> - <para>The <acronym xlink:href="https://www.w3.org/TR/xpath">XPath</acronym> - standard allows us to retrieve node sets from XML documents by predicate - based queries. Thus its role may be compared to <acronym + <para>The <acronym + xlink:href="https://www.w3.org/TR/xpath">XPath</acronym> standard allows + us to retrieve node sets from XML documents by predicate based queries. + Thus its role may be compared to <acronym xlink:href="https://en.wikipedia.org/wiki/Sql">SQL</acronym> <code>SELECT</code> ... <code>FROM</code> ...<code>WHERE</code> queries. Some simple examples:</para> @@ -461,7 +462,8 @@ Martin Goik</computeroutput></programlisting> of two nodes of type <tag class="starttag">to</tag> each of them representing a recipient of the memo. We observe a subtle difference between the two <abbrev - xlink:href="https://www.w3.org/TR/xpath">XPath</abbrev> expressions:</para> + xlink:href="https://www.w3.org/TR/xpath">XPath</abbrev> + expressions:</para> <glosslist> <glossentry> @@ -479,12 +481,12 @@ Martin Goik</computeroutput></programlisting> <para>A <abbrev xlink:href="https://www.w3.org/Style/XSL">XSL</abbrev> style sheet <emphasis>must</emphasis> have an <link - xlink:href="https://www.w3.org/TR/xslt20/#initiating">initial context - node</link> to start the transformation. This is achieved by + xlink:href="https://www.w3.org/TR/xslt20/#initiating">initial + context node</link> to start the transformation. This is achieved by providing exactly one <tag class="starttag">xsl:template</tag> with an absolute <abbrev - xlink:href="https://www.w3.org/TR/xpath">XPath</abbrev> value for its - <tag class="attribute">match</tag> attribute like <tag + xlink:href="https://www.w3.org/TR/xpath">XPath</abbrev> value for + its <tag class="attribute">match</tag> attribute like <tag class="attvalue">/memo</tag>.<emphasis/></para> </glossdef> </glossentry> @@ -606,10 +608,10 @@ Martin Goik</computeroutput></programlisting> <callout arearefs="programlisting_xsl_if_test"> <para>The attribute value of <tag class="attribute">test</tag> will be <link - xlink:href="https://www.w3.org/TR/xslt20/#xsl-if">evaluated</link> as - a boolean. In this example it evaluates to <code>true</code> iff the - attribute <tag class="attribute">id</tag> is defined for the context - node. Since we are inside the <tag + xlink:href="https://www.w3.org/TR/xslt20/#xsl-if">evaluated</link> + as a boolean. In this example it evaluates to <code>true</code> iff + the attribute <tag class="attribute">id</tag> is defined for the + context node. Since we are inside the <tag class="element">xsl:for-each</tag> block all context nodes are either of type <tag class="starttag">from</tag> or <tag class="starttag">to</tag> and thus <emphasis>may</emphasis> have an @@ -674,8 +676,8 @@ INSERT INTO Customer (id, name) VALUES ('eve', 'Eve intruder')</computeroutput>< and <link xlink:href="https://www.w3.org/TR/xpath#function-last">last()</link>. Hint: The arithmetic operator <quote><</quote> may be used in - <abbrev xlink:href="https://www.w3.org/Style/XSL">XSL</abbrev> to - compare two integer numbers. However it must be escaped as + <abbrev xlink:href="https://www.w3.org/Style/XSL">XSL</abbrev> + to compare two integer numbers. However it must be escaped as <code>&lt;</code> in order to be XML compatible.</para> </question> @@ -738,9 +740,9 @@ INSERT INTO Customer (id, name) VALUES ('eve', 'Eve intruder')</computeroutput>< <para>We already used <tag class="element">xsl:for-each</tag> to iterate over a list of element nodes. <abbrev - xlink:href="https://www.w3.org/Style/XSL">XSL</abbrev> offers a different - possibility for this purpose. The idea is to define the formatting rules - at a centralized location. So the solution to <xref + xlink:href="https://www.w3.org/Style/XSL">XSL</abbrev> offers a + different possibility for this purpose. The idea is to define the + formatting rules at a centralized location. So the solution to <xref linkend="example_position_last"/> in an equivalent way:</para> <programlisting language="xml"><xsl:template match="/"> @@ -1016,8 +1018,8 @@ IV: ... <para>Though <abbrev xlink:href="https://www.w3.org/Style/XSL">XSL</abbrev> offers <link - xlink:href="https://www.w3.org/TR/xslt20/#convert">a better way</link> we - may generate these number literals by:</para> + xlink:href="https://www.w3.org/TR/xslt20/#convert">a better way</link> + we may generate these number literals by:</para> <programlisting language="xml"><xsl:template match="/memo"> <xsl:apply-templates select="to"/> @@ -1560,8 +1562,8 @@ you need some </emphasis><em>time</em><emphasis role="bold">.</empha format text nodes being <emphasis>immediate</emphasis> children of <tag class="starttag">content</tag>. This may be achieved by restricting the <abbrev - xlink:href="https://www.w3.org/TR/xpath">XPath</abbrev> expression to - <tag class="starttag">xsl:template + xlink:href="https://www.w3.org/TR/xpath">XPath</abbrev> expression + to <tag class="starttag">xsl:template match="content/text()"</tag>.</para> </listitem> </orderedlist> @@ -2332,6 +2334,22 @@ Jack Eve Jude <----Tolstoi----> <co </glossdef> </glossentry> + <glossentry> + <glossterm>XSL identity transformation</glossterm> + + <glossdef> + <para><parameter>The following construct allows for a + generic <link + xlink:href="https://en.wikipedia.org/wiki/Tree_traversal#Depth-first_search">depth-first + traversal</link> of arbitrary <xref linkend="glo_XML"/> + input documents.</parameter><programlisting><xsl:template match="/ | @* | node()"> + <xsl:copy> + <xsl:apply-templates select="@* | node()" /> + </xsl:copy> +</xsl:template></programlisting></para> + </glossdef> + </glossentry> + <glossentry> <glossterm>Matching mixed content / arbitrary nodes</glossterm> -- GitLab