SlideShare une entreprise Scribd logo
1  sur  12
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

Intro to T-SQL - 1st session
Intro to T-SQL - 1st sessionIntro to T-SQL - 1st session
Intro to T-SQL - 1st sessionMedhat Dawoud
 
What is SQL Server?
What is SQL Server?What is SQL Server?
What is SQL Server?CPD INDIA
 
transforming xml using xsl and xslt
transforming xml using xsl and xslttransforming xml using xsl and xslt
transforming xml using xsl and xsltHemant Suthar
 
Sql a practical introduction
Sql   a practical introductionSql   a practical introduction
Sql a practical introductionHasan Kata
 
Difference Between Sql - MySql and Oracle
Difference Between Sql - MySql and OracleDifference Between Sql - MySql and Oracle
Difference Between Sql - MySql and OracleSteve Johnson
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic ConceptsTony Wong
 
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 1Dan D'Urso
 
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...Marco Gralike
 
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)Vidyasagar Mundroy
 

Tendances (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
 

En vedette (7)

Day4
Day4Day4
Day4
 
Lecture19-20
Lecture19-20Lecture19-20
Lecture19-20
 
collapsible-panels-tutorial
collapsible-panels-tutorialcollapsible-panels-tutorial
collapsible-panels-tutorial
 
geoext_dwins
geoext_dwinsgeoext_dwins
geoext_dwins
 
dr_1
dr_1dr_1
dr_1
 
handout
handouthandout
handout
 
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>
 

Similaire à treeview

Oracle Endeca Developer's Guide
Oracle Endeca Developer's GuideOracle Endeca Developer's Guide
Oracle Endeca Developer's GuideKeyur Shah
 
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...Marco Gralike
 
Ch23 xml processing_with_java
Ch23 xml processing_with_javaCh23 xml processing_with_java
Ch23 xml processing_with_javaardnetij
 
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 XmlDavid Truxall
 
What is struts_en
What is struts_enWhat is struts_en
What is struts_entechbed
 
Global objects in Node.pdf
Global objects in Node.pdfGlobal objects in Node.pdf
Global objects in Node.pdfSudhanshiBakre1
 
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 PatternDerek Novavi
 
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 Connectorsrtretola
 
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...Jerry SILVER
 
XML notes.pptx
XML notes.pptxXML notes.pptx
XML notes.pptxAmarYa2
 
Overview of atg framework
Overview of atg frameworkOverview of atg framework
Overview of atg frameworkYousuf Roushan
 
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 processHicham QAISSI
 
Dax Declarative Api For Xml
Dax   Declarative Api For XmlDax   Declarative Api For Xml
Dax Declarative Api For XmlLars Trieloff
 

Similaire à 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
 

Plus de 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
 
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 – INS0tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 
Winter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20JavascriptWinter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20Javascripttutorialsruby
 

Plus de 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" />
 
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
 
Winter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20JavascriptWinter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20Javascript
 

Dernier

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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 RobisonAnna Loughnan Colquhoun
 
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 WorkerThousandEyes
 
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 DevelopmentsTrustArc
 
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 Servicegiselly40
 
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 textsMaria Levchenko
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
[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.pdfhans926745
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
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 interpreternaman860154
 
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...Enterprise Knowledge
 

Dernier (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
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
 
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
 
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
 
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
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
[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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
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...
 

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