SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Downloaden Sie, um offline zu lesen
Tutorial: Recursive XSLT
This tutorial describes sample code that uses recursive XSLT calls and JavaScript to
display an expanding and collapsing tree view of an XML document.

Contents

  1. Concepts

  2. Design

  3. Required Software

  4. Setup

  5. Implementation

  6. Resources

  7. Feedback
Concepts
One of the strengths of XML as a language for data exchange is its flexibility. An XML
document can be transformed into many text formats, including HTML, PDF, and WML.
This tutorial uses XML, XSL and JavaScript to create an interactive view of a purchase
order. The combined code adds icons and user interface widgets that a user can click to
expand or collapse branches of a tree-style view (also called outline view) of the data in
an XML document.




About XML

XML stands for eXtensible Markup Language. Like HTML, XML is a subset of SGML
(Structured Generalized Markup Language), optimized for delivery over the Web. Unlike
HTML, which tags elements in Web pages for presentation by a browser, e.g.
<bold>Oracle</bold>, XML tags elements as data, e.g.
<company>Oracle</company>. For example, you can use XML to give context to
words and values in Web pages, identifying them as data instead of simple textual or
numeric elements.

About XSL

Unlike HTML, XML can keep the instructions for presenting data separate from the data
itself. The XML tags define the structure and content, and then a stylesheet is applied to
it to define the presentation. XML data can be presented in a variety of ways (both in
appearance and organization) simply by applying different stylesheets to it. For example,
a different interface can be presented to different users based on user profile, browser
type, or other criteria by defining a different stylesheet for each different presentation
style. Or, stylesheets can be used to transform XML data into a format tailored to the
specific application or device that receives and processes the data. Stylesheets may be
applied either on the server or on the client.

About JavaScript

Netscape's documentation describes JavaScript this way:

"JavaScript is Netscape's cross-platform, object-oriented scripting language. JavaScript
is a small, lightweight language; it is not useful as a standalone language, but is
designed for easy embedding in other products and applications, such as web browsers.
Inside a host environment, JavaScript can be connected to the objects of its environment
to provide programmatic control over them."
Design


The sample code for this tutorial was designed to demonstrate the following parsing
techniques:

   q   Using recursive calls in an XSL stylesheet.

   q   Invoking JavaScript code from an XSL stylesheet.
Required Software


The following software is required to build and run this tutorial.

   q   Java 2 Platform, (Standard Edition or Enterprise Edition) that includes Java
       Runtime Environment (JRE) 1.4. Available for download from
       http://java.sun.com/downloads.html. The Enterprise Edition (J2EE) is also included
       with Oracle9i JDeveloper, which OTN members can download for free.

   q   XDK Java Components in the Oracle XDK for Java, available for download from
       OTN and included with Oracle9i JDeveloper.

   q   Tutorial source code and supporting files (treeview.jar, 12.3 KB)

See the Setup section for information about installing and running the tutorial.
Setup


This section explains the steps to install and configure the tutorial. It assumes that you have installed and
configured the software described in the Required Software section.

  1. Download treeview.jar, a compressed Java Archive containing source code and other files.

   2. Open a command window and change directories to make the download directory active. For
      example, if you downloaded treeview.jar to d:tutorials, change directories to
      d:tutorials.

  3. Make sure that the executable file jar.exe (included with the Java 2 Platform) is in your
     environment's path. For example, the following command adds the path to a jar.exe that resides
     in d:jdevFolderjdkbin.

      set path=%path%;d:jdevFolderjdkbin

   4. From the command line, enter the following to unpack the archive. This command creates a
      directory named ex20030215_treeview that contains subdirectories and source files.

      jar -xvf treeview.jar

  5. Change directories to make the ex20030215_treeviewsrc directory active.

      cd ex20030215_treeviewsrc

  6. Set your CLASSPATH to include the path to your Java compiler (javac.exe) and the path to the
     Oracle XML Parser library (xmlparserv2.jar). For example,

      set CLASSPATH=.;..;d:jdevFolderjdkbin;d:jdevFolderlibxmlparserv2.jar

  7. Enter the following command to invoke the XDK tool that takes an XML document (po1_ann.xml)
     and applies an XSL stylesheet (treeview.xsl) to generate an HTML file (result.html).

      java oracle.xml.parser.v2.oraxsl po1_ann.xml treeview.xsl result.html

  8. Now you can load the generated HTML file (result.html) in a Web browser to display the results
     of the processing.
Implementation


This section lists the following key parts of the sample application:

   q   XML Input
   q   XSL Code
   q   JavaScript Code
   q   HTML Output

XML Input

The following XML code from po1_ann.xml defines the data for a purchase order,
including shipping and billing addresses and a list of items ordered.

<purchaseOrder orderDate="1999-10-20">
  <ShipTo isPicked="1" country="US">
    <name>Alice Smith</name>
    <street>123 Maple Street</street>
    <city>Mill Valley</city>
    <state>CA</state>
    <zip>90952</zip>
  </ShipTo>
  <BillTo isPicked="1" country="US">
    <name>Robert Smith</name>
    <street>8 Oak Avenue</street>
    <city>Old Town</city>
    <state>PA</state>
    <zip>95819</zip>
  </BillTo>
  <LineItems isPicked="1">
    <LineItem partNum="872-AA">
      <ProductName>Lawnmower</ProductName>
      <Quantity>1</Quantity>
      <USPrice>148.95</USPrice>
<comment>Confirm this is electric</comment>
    </LineItem>
    <LineItem partNum="926-AA">
      <ProductName>Baby Monitor</ProductName>
      <Quantity>1</Quantity>
      <USPrice>39.98</USPrice>
      <ShipDate>1999-05-21</ShipDate>
    </LineItem>
  </LineItems>
  <comment>Hurry, my lawn is going wild!</comment>
</purchaseOrder>

XSL Code

The XSL code below comes from treeview.xsl. It produces an HTML file that
includes calls to JavaScript code implemented in treemenu.js. Notice, too, that the
code defines a template named treeview that includes the element <xsl:call-
template name="treeview">. Thus this code uses recursion to process the input
data and create a hierarchical tree representation. The code also uses <xsl:when
test="number($depth)=0"> to record recursive depth and <xsl:when
test="$content/*"> to control the processing flow of the recursion.

...
 <xsl:template name="treeview">
    <xsl:param name="depth"/>
    <xsl:param name="content"/>
    <xsl:choose>
      <xsl:when test="number($depth)=0">
          foldersTree = gFld("Document Tree View", "")
         <xsl:for-each select="$content/*">
          <xsl:call-template name="treeview">
            <xsl:with-param name="content" select="."/>
            <xsl:with-param name="depth" select="number($depth)+1"/>
          </xsl:call-template>
        </xsl:for-each>
      </xsl:when>
      <xsl:otherwise>
        <xsl:choose>
          <xsl:when test="$content/*">
            <xsl:choose>
              ...
JavaScript Code

This sample application uses JavaScript to enable an otherwise static page to respond to
UI events, making the page interactive. For example, the following code from
treemenu.js defines responses when a user clicks on a folder icon (representing a
category of information such as Ship To data) or a document icon (representing a data
item such as a City name).

function clickOnFolder(folderId)
{
  var clicked = indexOfEntries[folderId]
  if (!clicked.isOpen)
    clickOnNode(folderId)
  return
  if (clicked.isSelected)
    return
}

function clickOnNode(folderId)
{
  var clickedFolder = 0
  var state = 0
  clickedFolder = indexOfEntries[folderId]
  state = clickedFolder.isOpen
  clickedFolder.setState(!state) //open<->close
}

HTML Output

The file result.html shows the HTML code generated when the sample application
processes the data in po1_ann.xml. The generated code includes calls to functions
implemented in the JavaScript file treemenu.js.
Resources


This tutorial is part of a series, Oracle XML Parser Techniques. Following are links to
resources that can help you understand and apply the concepts and techniques
presented in this tutorial. See the Required Software section to obtain the tutorial source
code and related files.


    Resource                                         URL

 OTN XML Center http://otn.oracle.com/tech/xml/content.html

 Oracle XDK for
                     http://otn.oracle.com/tech/xml/xdk_java/
 Java

 Oracle XML DB       http://otn.oracle.com/tech/xml/xmldb/content.html


 XML in Oracle
 Database            http://otn.oracle.com/tech/xml/htdocs/xml_in_oracle_apps.htm
 Applications

 Customizing
 Data                http://otn.oracle.com/tech/xml/htdocs/xml_custom_presentation.htm
 Presentation
Feedback


If you have questions or comments about this tutorial, you can:

   q   Post a message in the OTN Sample Code discussion forum. OTN developers and
       other experts monitor the forum.

   q   Send email to the author. mailto:Robert.Hall@oracle.com

If you have feedback about the XDK, please send email to:

   q   mailto:Jinyu.Wang@oracle.com

If you have suggestions or ideas for future tutorials, please send email to:

   q   mailto:Raghavan.Sarathy@oracle.com

Weitere ähnliche Inhalte

Was ist angesagt?

Sql a practical introduction
Sql   a practical introductionSql   a practical introduction
Sql a practical introduction
Hasan Kata
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic Concepts
Tony Wong
 

Was ist angesagt? (18)

Sql intro & ddl 1
Sql intro & ddl 1Sql intro & ddl 1
Sql intro & ddl 1
 
Intro to T-SQL - 1st session
Intro to T-SQL - 1st sessionIntro to T-SQL - 1st session
Intro to T-SQL - 1st session
 
What is SQL Server?
What is SQL Server?What is SQL Server?
What is SQL Server?
 
transforming xml using xsl and xslt
transforming xml using xsl and xslttransforming xml using xsl and xslt
transforming xml using xsl and xslt
 
Sql a practical introduction
Sql   a practical introductionSql   a practical introduction
Sql a practical introduction
 
Difference Between Sql - MySql and Oracle
Difference Between Sql - MySql and OracleDifference Between Sql - MySql and Oracle
Difference Between Sql - MySql and Oracle
 
Oracle SQL Part 2
Oracle SQL Part 2Oracle SQL Part 2
Oracle SQL Part 2
 
Learning XSLT
Learning XSLTLearning XSLT
Learning XSLT
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic Concepts
 
Chapter 18
Chapter 18Chapter 18
Chapter 18
 
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
 
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Oracle SQL Part 3
Oracle SQL Part 3Oracle SQL Part 3
Oracle SQL Part 3
 
Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)
 
Sql server
Sql serverSql server
Sql server
 
MS SQL Server
MS SQL ServerMS SQL Server
MS SQL Server
 

Andere mochten auch

SURE_2014 Poster 2.0
SURE_2014 Poster 2.0SURE_2014 Poster 2.0
SURE_2014 Poster 2.0
Alex Sumner
 
ScholarsDay_Poster2015_Sumner-Atay
ScholarsDay_Poster2015_Sumner-AtayScholarsDay_Poster2015_Sumner-Atay
ScholarsDay_Poster2015_Sumner-Atay
Alex Sumner
 
Web Page Authoring 1
Web Page Authoring 1Web Page Authoring 1
Web Page Authoring 1
yht4ever
 
Applications of SOA and Web Services in Grid Computing
Applications of SOA and Web Services in Grid ComputingApplications of SOA and Web Services in Grid Computing
Applications of SOA and Web Services in Grid Computing
yht4ever
 
Xsl Tand X Path Quick Reference
Xsl Tand X Path Quick ReferenceXsl Tand X Path Quick Reference
Xsl Tand X Path Quick Reference
LiquidHub
 
Common DataPower use cases, incl Caching with XC-10 appliance.
Common DataPower use cases, incl Caching with XC-10 appliance.Common DataPower use cases, incl Caching with XC-10 appliance.
Common DataPower use cases, incl Caching with XC-10 appliance.
sflynn073
 

Andere mochten auch (20)

SURE_2014 Poster 2.0
SURE_2014 Poster 2.0SURE_2014 Poster 2.0
SURE_2014 Poster 2.0
 
Rendering XML Document
Rendering XML DocumentRendering XML Document
Rendering XML Document
 
ScholarsDay_Poster2015_Sumner-Atay
ScholarsDay_Poster2015_Sumner-AtayScholarsDay_Poster2015_Sumner-Atay
ScholarsDay_Poster2015_Sumner-Atay
 
XML and XSLT
XML and XSLTXML and XSLT
XML and XSLT
 
WebSphere DataPower B2B Appliance overview
WebSphere DataPower B2B Appliance overviewWebSphere DataPower B2B Appliance overview
WebSphere DataPower B2B Appliance overview
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 
Xslt tutorial
Xslt tutorialXslt tutorial
Xslt tutorial
 
Transforming xml with XSLT
Transforming  xml with XSLTTransforming  xml with XSLT
Transforming xml with XSLT
 
Web Page Authoring 1
Web Page Authoring 1Web Page Authoring 1
Web Page Authoring 1
 
Applications of SOA and Web Services in Grid Computing
Applications of SOA and Web Services in Grid ComputingApplications of SOA and Web Services in Grid Computing
Applications of SOA and Web Services in Grid Computing
 
Rendering XML Documents
Rendering XML DocumentsRendering XML Documents
Rendering XML Documents
 
XSLT
XSLTXSLT
XSLT
 
Xquery
XqueryXquery
Xquery
 
Tracking Message Flows in DataPower With CA APM
Tracking Message Flows in DataPower With CA APMTracking Message Flows in DataPower With CA APM
Tracking Message Flows in DataPower With CA APM
 
XSLT
XSLTXSLT
XSLT
 
XML/XSLT
XML/XSLTXML/XSLT
XML/XSLT
 
Xsl Tand X Path Quick Reference
Xsl Tand X Path Quick ReferenceXsl Tand X Path Quick Reference
Xsl Tand X Path Quick Reference
 
XSLT and XPath - without the pain!
XSLT and XPath - without the pain!XSLT and XPath - without the pain!
XSLT and XPath - without the pain!
 
Common DataPower use cases, incl Caching with XC-10 appliance.
Common DataPower use cases, incl Caching with XC-10 appliance.Common DataPower use cases, incl Caching with XC-10 appliance.
Common DataPower use cases, incl Caching with XC-10 appliance.
 
Intorduction to Datapower
Intorduction to DatapowerIntorduction to Datapower
Intorduction to Datapower
 

Ähnlich wie treeview

What is struts_en
What is struts_enWhat is struts_en
What is struts_en
techbed
 
Jdom how it works & how it opened the java process
Jdom how it works & how it opened the java processJdom how it works & how it opened the java process
Jdom how it works & how it opened the java process
Hicham QAISSI
 

Ähnlich wie treeview (20)

Oracle Endeca Developer's Guide
Oracle Endeca Developer's GuideOracle Endeca Developer's Guide
Oracle Endeca Developer's Guide
 
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
 
Ch23
Ch23Ch23
Ch23
 
Ch23 xml processing_with_java
Ch23 xml processing_with_javaCh23 xml processing_with_java
Ch23 xml processing_with_java
 
Sql Summit Clr, Service Broker And Xml
Sql Summit   Clr, Service Broker And XmlSql Summit   Clr, Service Broker And Xml
Sql Summit Clr, Service Broker And Xml
 
Ibm
IbmIbm
Ibm
 
Adobe Flex4
Adobe Flex4 Adobe Flex4
Adobe Flex4
 
Practical OData
Practical ODataPractical OData
Practical OData
 
What is struts_en
What is struts_enWhat is struts_en
What is struts_en
 
Global objects in Node.pdf
Global objects in Node.pdfGlobal objects in Node.pdf
Global objects in Node.pdf
 
Xml writers
Xml writersXml writers
Xml writers
 
Silverlight Development & The Model-View-ViewModel Pattern
Silverlight Development & The Model-View-ViewModel PatternSilverlight Development & The Model-View-ViewModel Pattern
Silverlight Development & The Model-View-ViewModel Pattern
 
New Flash Builder 4 WSDL and HTTP Connectors
New Flash Builder 4 WSDL and HTTP ConnectorsNew Flash Builder 4 WSDL and HTTP Connectors
New Flash Builder 4 WSDL and HTTP Connectors
 
Struts 1
Struts 1Struts 1
Struts 1
 
Building a Scalable XML-based Dynamic Delivery Architecture: Standards and Be...
Building a Scalable XML-based Dynamic Delivery Architecture: Standards and Be...Building a Scalable XML-based Dynamic Delivery Architecture: Standards and Be...
Building a Scalable XML-based Dynamic Delivery Architecture: Standards and Be...
 
XML notes.pptx
XML notes.pptxXML notes.pptx
XML notes.pptx
 
Overview of atg framework
Overview of atg frameworkOverview of atg framework
Overview of atg framework
 
Sqllite
SqlliteSqllite
Sqllite
 
Jdom how it works & how it opened the java process
Jdom how it works & how it opened the java processJdom how it works & how it opened the java process
Jdom how it works & how it opened the java process
 
Dax Declarative Api For Xml
Dax   Declarative Api For XmlDax   Declarative Api For Xml
Dax Declarative Api For Xml
 

Mehr von tutorialsruby

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
tutorialsruby
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
tutorialsruby
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
tutorialsruby
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0
tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
tutorialsruby
 

Mehr von tutorialsruby (20)

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
CSS
CSSCSS
CSS
 
CSS
CSSCSS
CSS
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Kürzlich hochgeladen (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

treeview

  • 1. Tutorial: Recursive XSLT This tutorial describes sample code that uses recursive XSLT calls and JavaScript to display an expanding and collapsing tree view of an XML document. Contents 1. Concepts 2. Design 3. Required Software 4. Setup 5. Implementation 6. Resources 7. Feedback
  • 2. Concepts One of the strengths of XML as a language for data exchange is its flexibility. An XML document can be transformed into many text formats, including HTML, PDF, and WML. This tutorial uses XML, XSL and JavaScript to create an interactive view of a purchase order. The combined code adds icons and user interface widgets that a user can click to expand or collapse branches of a tree-style view (also called outline view) of the data in an XML document. About XML XML stands for eXtensible Markup Language. Like HTML, XML is a subset of SGML (Structured Generalized Markup Language), optimized for delivery over the Web. Unlike HTML, which tags elements in Web pages for presentation by a browser, e.g. <bold>Oracle</bold>, XML tags elements as data, e.g. <company>Oracle</company>. For example, you can use XML to give context to words and values in Web pages, identifying them as data instead of simple textual or numeric elements. About XSL Unlike HTML, XML can keep the instructions for presenting data separate from the data itself. The XML tags define the structure and content, and then a stylesheet is applied to it to define the presentation. XML data can be presented in a variety of ways (both in
  • 3. appearance and organization) simply by applying different stylesheets to it. For example, a different interface can be presented to different users based on user profile, browser type, or other criteria by defining a different stylesheet for each different presentation style. Or, stylesheets can be used to transform XML data into a format tailored to the specific application or device that receives and processes the data. Stylesheets may be applied either on the server or on the client. About JavaScript Netscape's documentation describes JavaScript this way: "JavaScript is Netscape's cross-platform, object-oriented scripting language. JavaScript is a small, lightweight language; it is not useful as a standalone language, but is designed for easy embedding in other products and applications, such as web browsers. Inside a host environment, JavaScript can be connected to the objects of its environment to provide programmatic control over them."
  • 4. Design The sample code for this tutorial was designed to demonstrate the following parsing techniques: q Using recursive calls in an XSL stylesheet. q Invoking JavaScript code from an XSL stylesheet.
  • 5. Required Software The following software is required to build and run this tutorial. q Java 2 Platform, (Standard Edition or Enterprise Edition) that includes Java Runtime Environment (JRE) 1.4. Available for download from http://java.sun.com/downloads.html. The Enterprise Edition (J2EE) is also included with Oracle9i JDeveloper, which OTN members can download for free. q XDK Java Components in the Oracle XDK for Java, available for download from OTN and included with Oracle9i JDeveloper. q Tutorial source code and supporting files (treeview.jar, 12.3 KB) See the Setup section for information about installing and running the tutorial.
  • 6. Setup This section explains the steps to install and configure the tutorial. It assumes that you have installed and configured the software described in the Required Software section. 1. Download treeview.jar, a compressed Java Archive containing source code and other files. 2. Open a command window and change directories to make the download directory active. For example, if you downloaded treeview.jar to d:tutorials, change directories to d:tutorials. 3. Make sure that the executable file jar.exe (included with the Java 2 Platform) is in your environment's path. For example, the following command adds the path to a jar.exe that resides in d:jdevFolderjdkbin. set path=%path%;d:jdevFolderjdkbin 4. From the command line, enter the following to unpack the archive. This command creates a directory named ex20030215_treeview that contains subdirectories and source files. jar -xvf treeview.jar 5. Change directories to make the ex20030215_treeviewsrc directory active. cd ex20030215_treeviewsrc 6. Set your CLASSPATH to include the path to your Java compiler (javac.exe) and the path to the Oracle XML Parser library (xmlparserv2.jar). For example, set CLASSPATH=.;..;d:jdevFolderjdkbin;d:jdevFolderlibxmlparserv2.jar 7. Enter the following command to invoke the XDK tool that takes an XML document (po1_ann.xml) and applies an XSL stylesheet (treeview.xsl) to generate an HTML file (result.html). java oracle.xml.parser.v2.oraxsl po1_ann.xml treeview.xsl result.html 8. Now you can load the generated HTML file (result.html) in a Web browser to display the results of the processing.
  • 7.
  • 8. Implementation This section lists the following key parts of the sample application: q XML Input q XSL Code q JavaScript Code q HTML Output XML Input The following XML code from po1_ann.xml defines the data for a purchase order, including shipping and billing addresses and a list of items ordered. <purchaseOrder orderDate="1999-10-20"> <ShipTo isPicked="1" country="US"> <name>Alice Smith</name> <street>123 Maple Street</street> <city>Mill Valley</city> <state>CA</state> <zip>90952</zip> </ShipTo> <BillTo isPicked="1" country="US"> <name>Robert Smith</name> <street>8 Oak Avenue</street> <city>Old Town</city> <state>PA</state> <zip>95819</zip> </BillTo> <LineItems isPicked="1"> <LineItem partNum="872-AA"> <ProductName>Lawnmower</ProductName> <Quantity>1</Quantity> <USPrice>148.95</USPrice>
  • 9. <comment>Confirm this is electric</comment> </LineItem> <LineItem partNum="926-AA"> <ProductName>Baby Monitor</ProductName> <Quantity>1</Quantity> <USPrice>39.98</USPrice> <ShipDate>1999-05-21</ShipDate> </LineItem> </LineItems> <comment>Hurry, my lawn is going wild!</comment> </purchaseOrder> XSL Code The XSL code below comes from treeview.xsl. It produces an HTML file that includes calls to JavaScript code implemented in treemenu.js. Notice, too, that the code defines a template named treeview that includes the element <xsl:call- template name="treeview">. Thus this code uses recursion to process the input data and create a hierarchical tree representation. The code also uses <xsl:when test="number($depth)=0"> to record recursive depth and <xsl:when test="$content/*"> to control the processing flow of the recursion. ... <xsl:template name="treeview"> <xsl:param name="depth"/> <xsl:param name="content"/> <xsl:choose> <xsl:when test="number($depth)=0"> foldersTree = gFld("Document Tree View", "") <xsl:for-each select="$content/*"> <xsl:call-template name="treeview"> <xsl:with-param name="content" select="."/> <xsl:with-param name="depth" select="number($depth)+1"/> </xsl:call-template> </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:choose> <xsl:when test="$content/*"> <xsl:choose> ...
  • 10. JavaScript Code This sample application uses JavaScript to enable an otherwise static page to respond to UI events, making the page interactive. For example, the following code from treemenu.js defines responses when a user clicks on a folder icon (representing a category of information such as Ship To data) or a document icon (representing a data item such as a City name). function clickOnFolder(folderId) { var clicked = indexOfEntries[folderId] if (!clicked.isOpen) clickOnNode(folderId) return if (clicked.isSelected) return } function clickOnNode(folderId) { var clickedFolder = 0 var state = 0 clickedFolder = indexOfEntries[folderId] state = clickedFolder.isOpen clickedFolder.setState(!state) //open<->close } HTML Output The file result.html shows the HTML code generated when the sample application processes the data in po1_ann.xml. The generated code includes calls to functions implemented in the JavaScript file treemenu.js.
  • 11. Resources This tutorial is part of a series, Oracle XML Parser Techniques. Following are links to resources that can help you understand and apply the concepts and techniques presented in this tutorial. See the Required Software section to obtain the tutorial source code and related files. Resource URL OTN XML Center http://otn.oracle.com/tech/xml/content.html Oracle XDK for http://otn.oracle.com/tech/xml/xdk_java/ Java Oracle XML DB http://otn.oracle.com/tech/xml/xmldb/content.html XML in Oracle Database http://otn.oracle.com/tech/xml/htdocs/xml_in_oracle_apps.htm Applications Customizing Data http://otn.oracle.com/tech/xml/htdocs/xml_custom_presentation.htm Presentation
  • 12. Feedback If you have questions or comments about this tutorial, you can: q Post a message in the OTN Sample Code discussion forum. OTN developers and other experts monitor the forum. q Send email to the author. mailto:Robert.Hall@oracle.com If you have feedback about the XDK, please send email to: q mailto:Jinyu.Wang@oracle.com If you have suggestions or ideas for future tutorials, please send email to: q mailto:Raghavan.Sarathy@oracle.com