• XSLT Processing Model

            Whe XSLT processor looks for a template, it searches the whole stylesheet, so it doesn't matter where the template is within that stylesheet. When the XSLT processor finds a matching template, it uses the content of the template to process the matching node and generate some output. Then content of the template might include insturctions that tell the processor to apply templates to a particular set of nodes, in which case it goes though those nodes finding the and processing matching templates, and so on.
    
  • Node tree

            <p>When XSLT processor read a xml document, it generates a node tree. The nodes can be one of the following.</p>
            <ul>
            <li>Element Nodes</li>
            <li>Attribute Nodes</li>
            <li>Text nodes</li>
            <li>Comment nodes</li>
            <li>Processing-instruction nodes</li>
            </ul>
            <p>
            Attribute nodes are a bit special because attributes are not contained in elements in the same way as other elements or text, but they are still associated with particular elements. the element that an attribute is associated with is still known as its parent, but attributes are not their parent element's children, just its attributes.
            </p>
    
  • simplified style sheet vs tempaltes based style sheet

                
                
                Hello World Example
                
                

  • transform to table

            <pre data-sub="prettyprint:_">
            <xsl:template match="/">
            <html>
            <body>
            <table>
            <tr>
            <xsl:for-each select ="*/*[1]/*">
            <td>
            <xsl:value-of select="local-name()" />
            </td>
            </xsl:for-each>
            </tr>
            <xsl:for-each select ="*/*">
            <tr>
            <xsl:for-each select="./*">
            <td>
            <xsl:value-of select="." />
            </td>
            </xsl:for-each>
            </tr>
            </xsl:for-each>
            </table>
            </body>
            </html>
            </xsl:template>
            </pre>
    
  • Property vs Method

    • If a property accessor has abserable side effects, implment a method instead of a property.
    • If the implementation of a property is considerably more expensive than that of a field, implementation a method instead. When you expose a property, you suggest to users that making frequent calls to it is acceptable. When you implement a method, you suggest to users that they save an reuse a returned value if they repeately need it.
    • If some properties require a user to set them in a predefined order, implement those properties as methods. In general, you should design your components so that properties can be set in any order.
    • If you need a write-only property, implement a method instead.