Re: ora:output

Subject: Re: ora:output
From: "Steve Muench" <smuench@xxxxxxxxxxxxx>
Date: Thu, 27 Jul 2000 08:42:49 -0700

As several people have mailed me on this, I've CC'd the
XSL-List so others might benefit from the example.

Using Oracle XSLT release or later ( is
the current production release since mid-July 2000), and
given an input document like:

<!-- people.xml -->

You can use an XSLT stylesheet given at the
bottom of this email -- which uses the <ora:output> built-in 
extension element -- to do the following:

  (1) Output a comma-separated list of all people to the
      default output "resource" using method="text"

  (2) Output odd-numbered people to an HTML file "odd.html"

  (3) Output even-numbered people to indented XML file "even.xml"

Using "oraxsl" to transform people.xml above by the stylesheet...

  $ oraxsl people.xml samplebelow.xsl defaultoutput.txt

below will produce:

  (1) The raw text output "Steve,Sebastian,Nacho,Michael"
      into the file "defaultoutput.txt"

  (2) The file "odd.html" that looks like:


  (3) The file "even.xml" that looks like:

      <?xml version = '1.0' encoding = 'UTF-8'?>

Here's the stylesheet...

<!-- Sample stylesheet using <ora:output> -->
<xsl:stylesheet version="1.0" exclude-result-prefixes="ora"

  <!-- NOTE: Trailing slash in "ora" URI above!! -->

  <!-- <xsl:output> controls default output resource's options -->
  <xsl:output method="text"/>

   | Top-level <ora:output> declares additional output resources
   | 'name' attribute assigns a name to the output resource
   | 'href' attribute provides URI of the file to receive output
   | In addition, <ora:output> supports all attributes of <xsl:output>
  <ora:output name="one" href="odd.html" method="html"/>
  <ora:output name="two" href="even.xml"  method="xml" indent="yes"/>

  <xsl:template match="/">
    <!-- No <ora:output use="xxx"> so use default result -->
    <xsl:apply-templates select="people/person" mode="list"/>

     | <ora:output use="one"> in a template instantiates
     | its contents such that it will be serialized to
     | the additional output resource named "one" declared above
    <ora:output use="one">
            <xsl:apply-templates select="people/person[position() mod 2 = 1]"/>

     | <ora:output use="two"> in a template instantiates
     | its contents such that it will be serialized to
     | the additional output resource named "two" declared above
    <ora:output use="two">
        <xsl:apply-templates select="people/person[position() mod 2 = 0]"/>

  <xsl:template match="people/person" mode="list">
    <xsl:value-of select="."/>
    <xsl:if test="not(position()=last())">,</xsl:if>

  <xsl:template match="people/person[position() mod 2 = 1]">
    <li><xsl:value-of select="."/></li>
  <xsl:template match="people/person[position() mod 2 = 0]">
    <Item><xsl:value-of select="."/></Item>

Steve Muench, Lead XML Evangelist & Consulting Product Manager
Business Components for Java & XSQL Servlet Development Teams
Oracle Rep to the W3C XSL Working Group
Author "Building Oracle XML Applications", O'Reilly, Oct 2000
----- Original Message ----- 
From: "Sebastian Rahtz" <sebastian.rahtz@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
To: <smuench@xxxxxxxxxxxxx>
Sent: Thursday, July 27, 2000 2:37 AM
Subject: ora:output

| I simply cant make this work. It just echos the ora:output to the
| normal output file. do you have a simple working example?
| sebastian

 XSL-List info and archive:

Current Thread