select attribute : select « XSLT stylesheet « XML Tutorial

XML Tutorial
1. Introduction
2. Namespace
3. XML Schema
4. XPath
5. XSLT stylesheet
Java
XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
XML Tutorial » XSLT stylesheet » select 
5. 66. 12. select attribute
File: Data.xml

<poem year="1667" type="epic">
  <verse>line 3</verse>
  <verse>line 4</verse>
</poem>

File: Transform.xslt

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">

  <xsl:template match="poem">
    <xsl:element name="ode">
      <xsl:element name="author">Jack</xsl:element>
      <xsl:element name="year">
        <xsl:value-of select="@year" />
      </xsl:element>
      <xsl:apply-templates />
    </xsl:element>
  </xsl:template>

  <xsl:template match="verse">
    <verse>
      <xsl:apply-templates />
    </verse>
  </xsl:template>

</xsl:stylesheet>

Output:

<?xml version="1.0" encoding="UTF-8"?><ode><author>Jack</author><year>1667</year>
  <verse>line 3</verse>
  <verse>line 4</verse>
</ode>
5. 66. select
5. 66. 1. select element by index
5. 66. 2. select value from attribute
5. 66. 3. select="@*|node()"
5. 66. 4. select="state[not(@founding)]"
5. 66. 5. select=count(document(other.xml)/eu/other/state)
5. 66. 6. select element by attribute value
5. 66. 7. Reference text after selecting tags and attributes
5. 66. 8. select element and attribute
5. 66. 9. match parent and select children
5. 66. 10. Match parent and select grand-children
5. 66. 11. Match a certain element
5. 66. 12. select attribute
5. 66. 13. Get value from an element with value-of and select
5. 66. 14. Select element out
5. 66. 15. select="operand[(. < 50) and (. > 30)]"
5. 66. 16. Selecting elements based on values of other ones.
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.