dleslie 00/12/05 05:35:35
Modified: java/samples/AppletXMLtoHTML rabbitwhorn.jpg
java/samples/ApplyXPath ApplyXPath.java
java/samples/Pipe Pipe.java
java/samples/SAX2SAX SAX2SAX.java
java/samples/SimpleTransform SimpleTransform.java
java/samples/Trace Trace.java
java/samples/UseXMLFilters UseXMLFilters.java
Added: java/samples/SAX2SAX birds.xml birds.xsl
java/samples/SimpleTransform birds.xml birds.xsl
Log:
Cleanup
Revision Changes Path
1.4 +1 -10 xml-xalan/java/samples/AppletXMLtoHTML/rabbitwhorn.jpg
<<Binary file>>
1.13 +2 -2 xml-xalan/java/samples/ApplyXPath/ApplyXPath.java
Index: ApplyXPath.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/ApplyXPath/ApplyXPath.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ApplyXPath.java 2000/11/20 15:04:52 1.12
+++ ApplyXPath.java 2000/12/05 13:35:31 1.13
@@ -61,8 +61,8 @@
import org.apache.xerces.parsers.DOMParser;
import org.apache.xpath.XPathAPI;
//import org.apache.xpath.xml.FormatterToXML;
-import org.apache.xalan.utils.TreeWalker;
-import org.apache.xalan.utils.DOMBuilder;
+import org.apache.xml.utils.TreeWalker;
+import org.apache.xml.utils.DOMBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.DocumentFragment;
1.6 +29 -22 xml-xalan/java/samples/Pipe/Pipe.java
Index: Pipe.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/Pipe/Pipe.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Pipe.java 2000/11/20 13:00:36 1.5
+++ Pipe.java 2000/12/05 13:35:32 1.6
@@ -64,6 +64,7 @@
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.dom.DOMResult;
@@ -108,29 +109,35 @@
throws TransformerException, TransformerConfigurationException,
SAXException, IOException
{
- // Instantiate a TransformerFactory.
+ // Instantiate a TransformerFactory.
TransformerFactory tFactory = TransformerFactory.newInstance();
- SAXTransformerFactory saxTFactory = (SAXTransformerFactory)tFactory;
- // Create a Transformer for each stylesheet.
- TransformerHandler tHandler1 = saxTFactory.newTransformerHandler(new
StreamSource("foo1.xsl"));
- TransformerHandler tHandler2 = saxTFactory.newTransformerHandler(new
StreamSource("foo2.xsl"));
- TransformerHandler tHandler3 = saxTFactory.newTransformerHandler(new
StreamSource("foo3.xsl"));
+ // Determine whether the TransformerFactory supports The use uf
SAXSource
+ // and SAXResult
+ if (tFactory.getFeature(SAXSource.FEATURE) &&
tFactory.getFeature(SAXResult.FEATURE))
+ {
+ // Cast the TransformerFactory to SAXTransformerFactory.
+ SAXTransformerFactory saxTFactory = ((SAXTransformerFactory)
tFactory);
+ // Create a TransformerHandler for each stylesheet.
+ TransformerHandler tHandler1 = saxTFactory.newTransformerHandler(new
StreamSource("foo1.xsl"));
+ TransformerHandler tHandler2 = saxTFactory.newTransformerHandler(new
StreamSource("foo2.xsl"));
+ TransformerHandler tHandler3 = saxTFactory.newTransformerHandler(new
StreamSource("foo3.xsl"));
- // Create an XMLReader.
- XMLReader reader = XMLReaderFactory.createXMLReader();
- reader.setContentHandler(tHandler1);
- reader.setProperty("http://xml.org/sax/properties/lexical-handler",
tHandler1);
-
- tHandler1.setResult(new SAXResult(tHandler2));
- tHandler2.setResult(new SAXResult(tHandler3));
-
- // transformer3 outputs SAX events to the serializer.
- Serializer serializer = SerializerFactory.getSerializer("xml");
- serializer.setOutputStream(System.out);
- tHandler3.setResult(new SAXResult(serializer.asContentHandler()));
-
- // Parse the XML input document. The input ContentHandler and output
ContentHandler
- // work in separate threads to optimize performance.
- reader.parse("foo.xml");
+ // Create an XMLReader.
+ XMLReader reader = XMLReaderFactory.createXMLReader();
+ reader.setContentHandler(tHandler1);
+ reader.setProperty("http://xml.org/sax/properties/lexical-handler",
tHandler1);
+
+ tHandler1.setResult(new SAXResult(tHandler2));
+ tHandler2.setResult(new SAXResult(tHandler3));
+
+ // transformer3 outputs SAX events to the serializer.
+ Serializer serializer = SerializerFactory.getSerializer("xml");
+ serializer.setOutputStream(System.out);
+ tHandler3.setResult(new SAXResult(serializer.asContentHandler()));
+
+ // Parse the XML input document. The input ContentHandler and
output ContentHandler
+ // work in separate threads to optimize performance.
+ reader.parse("foo.xml");
+ }
}
}
1.7 +9 -9 xml-xalan/java/samples/SAX2SAX/SAX2SAX.java
Index: SAX2SAX.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/SAX2SAX/SAX2SAX.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SAX2SAX.java 2000/11/21 17:38:48 1.6
+++ SAX2SAX.java 2000/12/05 13:35:32 1.7
@@ -96,29 +96,29 @@
SAXException, IOException
{
- // Instantiate a TransformerFactory.
+ // Instantiate a TransformerFactory.
TransformerFactory tFactory = TransformerFactory.newInstance();
- // Determine whether the TransformerFactory supports The use uf
SAXSource
+ // Determine whether the TransformerFactory supports The use of
SAXSource
// and SAXResult
if (tFactory.getFeature(SAXSource.FEATURE) &&
tFactory.getFeature(SAXResult.FEATURE))
{
// Cast the TransformerFactory.
- SAXTransformerFactory stFactory = ((SAXTransformerFactory) tFactory);
+ SAXTransformerFactory saxTFactory = ((SAXTransformerFactory) tFactory);
// Create a ContentHandler to handle parsing of the stylesheet.
- TemplatesHandler templatesHandler = stFactory.newTemplatesHandler();
+ TemplatesHandler templatesHandler = saxTFactory.newTemplatesHandler();
// Create an XMLReader and set its ContentHandler.
XMLReader reader = XMLReaderFactory.createXMLReader();
reader.setContentHandler(templatesHandler);
// Parse the stylesheet.
- reader.parse("foo.xsl");
+ reader.parse("birds.xsl");
//Get the Templates object from the ContentHandler.
Templates templates = templatesHandler.getTemplates();
// Create a ContentHandler to handle parsing of the XML source.
TransformerHandler handler
- = stFactory.newTransformerHandler(templates);
+ = saxTFactory.newTransformerHandler(templates);
// Reset the XMLReader's ContentHandler.
reader.setContentHandler(handler);
@@ -126,7 +126,7 @@
// includes "lexical" events (e.g., comments and CDATA).
reader.setProperty("http://xml.org/sax/properties/lexical-handler",
handler);
- FileOutputStream fos = new FileOutputStream("foo.out");
+ FileOutputStream fos = new FileOutputStream("birds.out");
Serializer serializer = SerializerFactory.getSerializer("xml");
serializer.setOutputStream(fos);
@@ -136,9 +136,9 @@
handler.setResult(result);
// Parse the XML input document.
- reader.parse("foo.xml");
+ reader.parse("birds.xml");
- System.out.println("************* The result is in foo.out
*************");
+ System.out.println("************* The result is in birds.out
*************");
}
else
System.out.println("The TransformerFactory does not support SAX input
and SAX output");
1.1 xml-xalan/java/samples/SAX2SAX/birds.xml
Index: birds.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<Class>
<Order Name="TINAMIFORMES">
<Family Name="TINAMIDAE">
<Species Scientific_Name="Tinamus major"> Great
Tinamou.</Species>
<Species Scientific_Name="Nothocercus">Highland Tinamou.</Species>
<Species Scientific_Name="Crypturellus soui">Little
Tinamou.</Species>
<Species Scientific_Name="Crypturellus cinnamomeus">Thicket
Tinamou.</Species>
<Species Scientific_Name="Crypturellus boucardi">Slaty-breasted
Tinamou.</Species>
<Species Scientific_Name="Crypturellus kerriae">Choco
Tinamou.</Species>
</Family>
</Order>
<Order Name="GAVIIFORMES">
<Family Name="GAVIIDAE">
<Species Scientific_Name="Gavia stellata">Red-throated
Loon.</Species>
<Species Scientific_Name="Gavia arctica">Arctic Loon.</Species>
<Species Scientific_Name="Gavia pacifica">Pacific Loon.</Species>
<Species Scientific_Name="Gavia immer">Common Loon.</Species>
<Species Scientific_Name="Gavia adamsii">Yellow-billed
Loon.</Species>
</Family>
</Order>
<Order Name="PODICIPEDIFORMES">
<Family Name="PODICIPEDIDAE">
<Species Scientific_Name="Tachybaptus dominicus">Least
Grebe.</Species>
<Species Scientific_Name="Podilymbus podiceps">Pied-billed
Grebe.</Species>
<Species Scientific_Name="">Atitlan Grebe.</Species>
<Species Scientific_Name="">Horned Grebe.</Species>
<Species Scientific_Name="">Red-necked Grebe.</Species>
<Species Scientific_Name="">Eared Grebe.</Species>
<Species Scientific_Name="">Western Grebe.</Species>
<Species Scientific_Name="">Clark's Grebe.</Species>
<Species Scientific_Name=""/>
</Family>
</Order>
<Order Name="PROCELLARIIFORMES">
<Family Name="DIOMEDEIDAE">
<Species Scientific_Name="Thalassarche
chlororhynchos">Yellow-nosed Albatross. (A)</Species>
<Species Scientific_Name="Thalassarche cauta">Shy Albatross.
(A)</Species>
<Species Scientific_Name="Thalassarche melanophris">Black-browed
Albatross. (A)</Species>
<Species Scientific_Name="Phoebetria palpebrata">Light-mantled
Albatross. (A)</Species>
<Species Scientific_Name="Diomedea exulans">Wandering Albatross.
(A)</Species>
<Species Scientific_Name="Phoebastria immutabilis">Laysan
Albatross.</Species>
<Species Scientific_Name="Phoebastria nigripes">Black-footed
Albatross.</Species>
<Species Scientific_Name="Phoebastria albatrus">Short-tailed
Albatross. (N)</Species>
</Family>
<Family Name="PROCELLARIIDAE">
<Species Scientific_Name="Fulmarus glacialis">Northern
Fulmar.</Species>
<Species Scientific_Name="Pterodroma neglecta">Kermadec Petrel.
(A)</Species>
<Species Scientific_Name="Pterodroma arminjoniana">Herald Petrel.
(A)</Species>
<Species Scientific_Name="Pterodroma ultima">Murphy's Petrel.
(N)</Species>
<Species Scientific_Name="Pterodroma inexpectata">Mottled Petrel.
(A)</Species>
<Species Scientific_Name="Pterodroma cahow">Bermuda
Petrel.</Species>
<Species Scientific_Name="Pterodroma hasitata">Black-capped
Petrel.</Species>
<Species Scientific_Name="Pterodroma externa">Juan Fernandez
Petrel. (N)</Species>
<Species Scientific_Name="Pterodroma phaeopygia">Dark-rumped
Petrel.</Species>
<Species Scientific_Name="Pterodroma cervicalis">White-necked
Petrel. (H)</Species>
<Species Scientific_Name="Pterodroma hypoleuca">Bonin Petrel.
(H)</Species>
<Species Scientific_Name="Pterodroma nigripennis">Black-winged
Petrel. (H, A)</Species>
<Species Scientific_Name="Pterodroma cookii">Cook's Petrel.
(N)</Species>
<Species Scientific_Name="Pterodroma longirostris">Stejneger's
Petrel. (A)</Species>
<Species Scientific_Name="Bulweria bulwerii">Bulwer's Petrel.
(H)</Species>
<Species Scientific_Name="Bulweria fallax">Jouanin's Petrel. (H,
A)</Species>
<Species Scientific_Name="Procellaria parkinsoni">Parkinson's
Petrel. (N)</Species>
<Species Scientific_Name="Calonectris leucomelas">Streaked
Shearwater. (A)</Species>
<Species Scientific_Name="Calonectris diomedea">Cory's
Shearwater. (N)</Species>
<Species Scientific_Name="Puffinus creatopus">Pink-footed
Shearwater. (N)</Species>
<Species Scientific_Name="Puffinus carneipes">Flesh-footed
Shearwater. (N)</Species>
<Species Scientific_Name="Puffinus gravis">Greater Shearwater.
(N)</Species>
<Species Scientific_Name="Puffinus pacificus">Wedge-tailed
Shearwater.</Species>
<Species Scientific_Name="Puffinus bulleri">Buller's Shearwater.
(N)</Species>
<Species Scientific_Name="Puffinus griseus">Sooty Shearwater.
(N)</Species>
<Species Scientific_Name="Puffinus tenuirostris">Short-tailed
Shearwater. (N)</Species>
<Species Scientific_Name="Puffinus nativitatis">Christmas
Shearwater. (H)</Species>
<Species Scientific_Name="Puffinus puffinus">Manx
Shearwater.</Species>
<Species Scientific_Name="Puffinus auricularis">Townsend's
Shearwater.</Species>
<Species Scientific_Name="Puffinus opisthomelas">Black-vented
Shearwater.</Species>
<Species Scientific_Name="Puffinus lherminieri">Audubon's
Shearwater.</Species>
<Species Scientific_Name="Puffinus assimilis">Little Shearwater.
(A)</Species>
</Family>
<Family Name="HYDROBATIDAE">
<Species Scientific_Name="Oceanites oceanicus">Wilson's
Storm-Petrel. (N)</Species>
<Species Scientific_Name="Pelagodroma marina">White-faced
Storm-Petrel. (A)</Species>
<Species Scientific_Name="Hydrobates pelagicus">European
Storm-Petrel. (A)</Species>
<Species Scientific_Name="Oceanodroma furcata">Fork-tailed
Storm-Petrel.</Species>
<Species Scientific_Name="Oceanodroma leucorhoa">Leach's
Storm-Petrel.</Species>
<Species Scientific_Name="Oceanodroma homochroa">Ashy
Storm-Petrel.</Species>
<Species Scientific_Name="Oceanodroma castro">Band-rumped
Storm-Petrel. (N)</Species>
<Species Scientific_Name="Oceanodroma tethys">Wedge-rumped
Storm-Petrel. (N)</Species>
<Species Scientific_Name="Oceanodroma melania">Black
Storm-Petrel.</Species>
<Species Scientific_Name="Oceanodroma macrodactyla">Guadalupe
Storm-Petrel.</Species>
<Species Scientific_Name="Oceanodroma markhami">Markham's
Storm-Petrel. (A)</Species>
<Species Scientific_Name="Oceanodroma tristrami">Tristram's
Storm-Petrel. (H)</Species>
<Species Scientific_Name="Oceanodroma microsoma">Least
Storm-Petrel.</Species>
</Family>
</Order>
<Order Name="PELECANIFORMES">
<Family Name="PHAETHONTIDAE">
<Species Scientific_Name="Phaethon lepturus">White-tailed
Tropicbird.</Species>
<Species Scientific_Name="Phaethon aethereus">Red-billed
Tropicbird.</Species>
<Species Scientific_Name="Phaethon rubricauda">Red-tailed
Tropicbird.</Species>
</Family>
<Family Name="SULIDAE">
<Species Scientific_Name="Sula dactylatra">Masked Booby.</Species>
<Species Scientific_Name="Sula nebouxii">Blue-footed
Booby.</Species>
<Species Scientific_Name="Sula variegata">Peruvian Booby.
(A)</Species>
<Species Scientific_Name="Sula leucogaster">Brown Booby.</Species>
<Species Scientific_Name="Sula sula">Red-footed Booby.</Species>
<Species Scientific_Name="Morus bassanus">Northern
Gannet.</Species>
</Family>
<Family Name="PELECANIDAE">
<Species Scientific_Name="Pelecanus erythrorhynchos">American
White Pelican.</Species>
<Species Scientific_Name="Pelecanus occidentalis">Brown
Pelican.</Species>
</Family>
<Family Name="PHALACROCORACIDAE">
<Species Scientific_Name="Phalacrocorax penicillatus">Brandt's
Cormorant.</Species>
<Species Scientific_Name="Phalacrocorax brasilianus">Neotropic
Cormorant.</Species>
<Species Scientific_Name="Phalacrocorax auritus">Double-crested
Cormorant.</Species>
<Species Scientific_Name="Phalacrocorax carbo">Great
Cormorant.</Species>
<Species Scientific_Name="Phalacrocorax urile">Red-faced
Cormorant.</Species>
<Species Scientific_Name="Phalacrocorax pelagicus">Pelagic
Cormorant.</Species>
</Family>
<Family Name="ANHINGIDAE">
<Species Scientific_Name="Anhinga anhinga">Anhinga.</Species>
</Family>
<Family Name="FREGATIDAE">
<Species Scientific_Name="Fregata magnificens">Magnificent
Frigatebird.</Species>
<Species Scientific_Name="Fregata minor">Great
Frigatebird.</Species>
<Species Scientific_Name="Fregata ariel">Lesser Frigatebird.
(A)</Species>
</Family>
</Order>
</Class>
1.1 xml-xalan/java/samples/SAX2SAX/birds.xsl
Index: birds.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="Class">
<BirdInfo>
<xsl:apply-templates select="Order"/>
</BirdInfo>
</xsl:template>
<xsl:template match="Order">
Order is: <xsl:value-of select="@Name"/>
<xsl:apply-templates select="Family"/><xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="Family">
Family is: <xsl:value-of select="@Name"/>
<xsl:apply-templates select="Species | SubFamily | text()"/>
</xsl:template>
<xsl:template match="SubFamily">
SubFamily is <xsl:value-of select="@Name"/>
<xsl:apply-templates select="Species | text()"/>
</xsl:template>
<xsl:template match="Species">
<xsl:choose>
<xsl:when test="name(..)='SubFamily'">
<xsl:text> </xsl:text><xsl:value-of select="."/><xsl:text>
</xsl:text><xsl:value-of select="@Scientific_Name"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/><xsl:text> </xsl:text><xsl:value-of
select="@Scientific_Name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
1.5 +3 -3
xml-xalan/java/samples/SimpleTransform/SimpleTransform.java
Index: SimpleTransform.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/samples/SimpleTransform/SimpleTransform.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SimpleTransform.java 2000/11/16 22:02:32 1.4
+++ SimpleTransform.java 2000/12/05 13:35:33 1.5
@@ -89,12 +89,12 @@
// Use the TransformerFactory to instantiate a Transformer that will
work with
// the stylesheet you specify. This method call also processes the
stylesheet
// into a compiled Templates object.
- Transformer transformer = tFactory.newTransformer(new
StreamSource("foo.xsl"));
+ Transformer transformer = tFactory.newTransformer(new
StreamSource("birds.xsl"));
// Use the Transformer to apply the associated Templates object to an
XML document
// (foo.xml) and write the output to a file (foo.out).
- transformer.transform(new StreamSource("foo.xml"), new StreamResult(new
FileOutputStream("foo.out")));
+ transformer.transform(new StreamSource("birds.xml"), new
StreamResult(new FileOutputStream("birds.out")));
- System.out.println("************* The result is in foo.out
*************");
+ System.out.println("************* The result is in birds.out
*************");
}
}
1.1 xml-xalan/java/samples/SimpleTransform/birds.xml
Index: birds.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<Class>
<Order Name="TINAMIFORMES">
<Family Name="TINAMIDAE">
<Species Scientific_Name="Tinamus major"> Great
Tinamou.</Species>
<Species Scientific_Name="Nothocercus">Highland Tinamou.</Species>
<Species Scientific_Name="Crypturellus soui">Little
Tinamou.</Species>
<Species Scientific_Name="Crypturellus cinnamomeus">Thicket
Tinamou.</Species>
<Species Scientific_Name="Crypturellus boucardi">Slaty-breasted
Tinamou.</Species>
<Species Scientific_Name="Crypturellus kerriae">Choco
Tinamou.</Species>
</Family>
</Order>
<Order Name="GAVIIFORMES">
<Family Name="GAVIIDAE">
<Species Scientific_Name="Gavia stellata">Red-throated
Loon.</Species>
<Species Scientific_Name="Gavia arctica">Arctic Loon.</Species>
<Species Scientific_Name="Gavia pacifica">Pacific Loon.</Species>
<Species Scientific_Name="Gavia immer">Common Loon.</Species>
<Species Scientific_Name="Gavia adamsii">Yellow-billed
Loon.</Species>
</Family>
</Order>
<Order Name="PODICIPEDIFORMES">
<Family Name="PODICIPEDIDAE">
<Species Scientific_Name="Tachybaptus dominicus">Least
Grebe.</Species>
<Species Scientific_Name="Podilymbus podiceps">Pied-billed
Grebe.</Species>
<Species Scientific_Name="">Atitlan Grebe.</Species>
<Species Scientific_Name="">Horned Grebe.</Species>
<Species Scientific_Name="">Red-necked Grebe.</Species>
<Species Scientific_Name="">Eared Grebe.</Species>
<Species Scientific_Name="">Western Grebe.</Species>
<Species Scientific_Name="">Clark's Grebe.</Species>
<Species Scientific_Name=""/>
</Family>
</Order>
<Order Name="PROCELLARIIFORMES">
<Family Name="DIOMEDEIDAE">
<Species Scientific_Name="Thalassarche
chlororhynchos">Yellow-nosed Albatross. (A)</Species>
<Species Scientific_Name="Thalassarche cauta">Shy Albatross.
(A)</Species>
<Species Scientific_Name="Thalassarche melanophris">Black-browed
Albatross. (A)</Species>
<Species Scientific_Name="Phoebetria palpebrata">Light-mantled
Albatross. (A)</Species>
<Species Scientific_Name="Diomedea exulans">Wandering Albatross.
(A)</Species>
<Species Scientific_Name="Phoebastria immutabilis">Laysan
Albatross.</Species>
<Species Scientific_Name="Phoebastria nigripes">Black-footed
Albatross.</Species>
<Species Scientific_Name="Phoebastria albatrus">Short-tailed
Albatross. (N)</Species>
</Family>
<Family Name="PROCELLARIIDAE">
<Species Scientific_Name="Fulmarus glacialis">Northern
Fulmar.</Species>
<Species Scientific_Name="Pterodroma neglecta">Kermadec Petrel.
(A)</Species>
<Species Scientific_Name="Pterodroma arminjoniana">Herald Petrel.
(A)</Species>
<Species Scientific_Name="Pterodroma ultima">Murphy's Petrel.
(N)</Species>
<Species Scientific_Name="Pterodroma inexpectata">Mottled Petrel.
(A)</Species>
<Species Scientific_Name="Pterodroma cahow">Bermuda
Petrel.</Species>
<Species Scientific_Name="Pterodroma hasitata">Black-capped
Petrel.</Species>
<Species Scientific_Name="Pterodroma externa">Juan Fernandez
Petrel. (N)</Species>
<Species Scientific_Name="Pterodroma phaeopygia">Dark-rumped
Petrel.</Species>
<Species Scientific_Name="Pterodroma cervicalis">White-necked
Petrel. (H)</Species>
<Species Scientific_Name="Pterodroma hypoleuca">Bonin Petrel.
(H)</Species>
<Species Scientific_Name="Pterodroma nigripennis">Black-winged
Petrel. (H, A)</Species>
<Species Scientific_Name="Pterodroma cookii">Cook's Petrel.
(N)</Species>
<Species Scientific_Name="Pterodroma longirostris">Stejneger's
Petrel. (A)</Species>
<Species Scientific_Name="Bulweria bulwerii">Bulwer's Petrel.
(H)</Species>
<Species Scientific_Name="Bulweria fallax">Jouanin's Petrel. (H,
A)</Species>
<Species Scientific_Name="Procellaria parkinsoni">Parkinson's
Petrel. (N)</Species>
<Species Scientific_Name="Calonectris leucomelas">Streaked
Shearwater. (A)</Species>
<Species Scientific_Name="Calonectris diomedea">Cory's
Shearwater. (N)</Species>
<Species Scientific_Name="Puffinus creatopus">Pink-footed
Shearwater. (N)</Species>
<Species Scientific_Name="Puffinus carneipes">Flesh-footed
Shearwater. (N)</Species>
<Species Scientific_Name="Puffinus gravis">Greater Shearwater.
(N)</Species>
<Species Scientific_Name="Puffinus pacificus">Wedge-tailed
Shearwater.</Species>
<Species Scientific_Name="Puffinus bulleri">Buller's Shearwater.
(N)</Species>
<Species Scientific_Name="Puffinus griseus">Sooty Shearwater.
(N)</Species>
<Species Scientific_Name="Puffinus tenuirostris">Short-tailed
Shearwater. (N)</Species>
<Species Scientific_Name="Puffinus nativitatis">Christmas
Shearwater. (H)</Species>
<Species Scientific_Name="Puffinus puffinus">Manx
Shearwater.</Species>
<Species Scientific_Name="Puffinus auricularis">Townsend's
Shearwater.</Species>
<Species Scientific_Name="Puffinus opisthomelas">Black-vented
Shearwater.</Species>
<Species Scientific_Name="Puffinus lherminieri">Audubon's
Shearwater.</Species>
<Species Scientific_Name="Puffinus assimilis">Little Shearwater.
(A)</Species>
</Family>
<Family Name="HYDROBATIDAE">
<Species Scientific_Name="Oceanites oceanicus">Wilson's
Storm-Petrel. (N)</Species>
<Species Scientific_Name="Pelagodroma marina">White-faced
Storm-Petrel. (A)</Species>
<Species Scientific_Name="Hydrobates pelagicus">European
Storm-Petrel. (A)</Species>
<Species Scientific_Name="Oceanodroma furcata">Fork-tailed
Storm-Petrel.</Species>
<Species Scientific_Name="Oceanodroma leucorhoa">Leach's
Storm-Petrel.</Species>
<Species Scientific_Name="Oceanodroma homochroa">Ashy
Storm-Petrel.</Species>
<Species Scientific_Name="Oceanodroma castro">Band-rumped
Storm-Petrel. (N)</Species>
<Species Scientific_Name="Oceanodroma tethys">Wedge-rumped
Storm-Petrel. (N)</Species>
<Species Scientific_Name="Oceanodroma melania">Black
Storm-Petrel.</Species>
<Species Scientific_Name="Oceanodroma macrodactyla">Guadalupe
Storm-Petrel.</Species>
<Species Scientific_Name="Oceanodroma markhami">Markham's
Storm-Petrel. (A)</Species>
<Species Scientific_Name="Oceanodroma tristrami">Tristram's
Storm-Petrel. (H)</Species>
<Species Scientific_Name="Oceanodroma microsoma">Least
Storm-Petrel.</Species>
</Family>
</Order>
<Order Name="PELECANIFORMES">
<Family Name="PHAETHONTIDAE">
<Species Scientific_Name="Phaethon lepturus">White-tailed
Tropicbird.</Species>
<Species Scientific_Name="Phaethon aethereus">Red-billed
Tropicbird.</Species>
<Species Scientific_Name="Phaethon rubricauda">Red-tailed
Tropicbird.</Species>
</Family>
<Family Name="SULIDAE">
<Species Scientific_Name="Sula dactylatra">Masked Booby.</Species>
<Species Scientific_Name="Sula nebouxii">Blue-footed
Booby.</Species>
<Species Scientific_Name="Sula variegata">Peruvian Booby.
(A)</Species>
<Species Scientific_Name="Sula leucogaster">Brown Booby.</Species>
<Species Scientific_Name="Sula sula">Red-footed Booby.</Species>
<Species Scientific_Name="Morus bassanus">Northern
Gannet.</Species>
</Family>
<Family Name="PELECANIDAE">
<Species Scientific_Name="Pelecanus erythrorhynchos">American
White Pelican.</Species>
<Species Scientific_Name="Pelecanus occidentalis">Brown
Pelican.</Species>
</Family>
<Family Name="PHALACROCORACIDAE">
<Species Scientific_Name="Phalacrocorax penicillatus">Brandt's
Cormorant.</Species>
<Species Scientific_Name="Phalacrocorax brasilianus">Neotropic
Cormorant.</Species>
<Species Scientific_Name="Phalacrocorax auritus">Double-crested
Cormorant.</Species>
<Species Scientific_Name="Phalacrocorax carbo">Great
Cormorant.</Species>
<Species Scientific_Name="Phalacrocorax urile">Red-faced
Cormorant.</Species>
<Species Scientific_Name="Phalacrocorax pelagicus">Pelagic
Cormorant.</Species>
</Family>
<Family Name="ANHINGIDAE">
<Species Scientific_Name="Anhinga anhinga">Anhinga.</Species>
</Family>
<Family Name="FREGATIDAE">
<Species Scientific_Name="Fregata magnificens">Magnificent
Frigatebird.</Species>
<Species Scientific_Name="Fregata minor">Great
Frigatebird.</Species>
<Species Scientific_Name="Fregata ariel">Lesser Frigatebird.
(A)</Species>
</Family>
</Order>
</Class>
1.1 xml-xalan/java/samples/SimpleTransform/birds.xsl
Index: birds.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="Class">
<BirdInfo>
<xsl:apply-templates select="Order"/>
</BirdInfo>
</xsl:template>
<xsl:template match="Order">
Order is: <xsl:value-of select="@Name"/>
<xsl:apply-templates select="Family"/><xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="Family">
Family is: <xsl:value-of select="@Name"/>
<xsl:apply-templates select="Species | SubFamily | text()"/>
</xsl:template>
<xsl:template match="SubFamily">
SubFamily is <xsl:value-of select="@Name"/>
<xsl:apply-templates select="Species | text()"/>
</xsl:template>
<xsl:template match="Species">
<xsl:choose>
<xsl:when test="name(..)='SubFamily'">
<xsl:text> </xsl:text><xsl:value-of select="."/><xsl:text>
</xsl:text><xsl:value-of select="@Scientific_Name"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/><xsl:text> </xsl:text><xsl:value-of
select="@Scientific_Name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
1.3 +3 -4 xml-xalan/java/samples/Trace/Trace.java
Index: Trace.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/Trace/Trace.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Trace.java 2000/11/20 13:01:33 1.2
+++ Trace.java 2000/12/05 13:35:34 1.3
@@ -30,14 +30,13 @@
// Print information whenever a template is invoked.
ptl.m_traceTemplates = true;
- // Set up the transformation
-
+ // Set up the transformation
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new
StreamSource("foo.xsl"));
- // Cast the Transformer object as TransformerImpl.
+ // Cast the Transformer object to TransformerImpl.
if (transformer instanceof TransformerImpl)
- {
+ {
TransformerImpl transformerImpl = (TransformerImpl)transformer;
// Register the TraceListener with a TraceManager associated
// with the TransformerImpl.
1.5 +39 -33 xml-xalan/java/samples/UseXMLFilters/UseXMLFilters.java
Index: UseXMLFilters.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/UseXMLFilters/UseXMLFilters.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- UseXMLFilters.java 2000/11/20 13:02:25 1.4
+++ UseXMLFilters.java 2000/12/05 13:35:35 1.5
@@ -88,7 +88,7 @@
import org.apache.xalan.serialize.Serializer;
import org.apache.xalan.serialize.SerializerFactory;
-// Imported JAVA API for XML Parsing 1.0 classes
+// Imported JAVA API for XML Parsing classes
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@@ -110,43 +110,49 @@
SAXException, IOException
{
// Instantiate a TransformerFactory.
- SAXTransformerFactory saxTFactory =
(SAXTransformerFactory)TransformerFactory.newInstance();
-
- // Create a a Transformer for each stylesheet.
- XMLFilter xmlFilter1 = saxTFactory.newXMLFilter(new
StreamSource("foo1.xsl"));
- XMLFilter xmlFilter2 = saxTFactory.newXMLFilter(new
StreamSource("foo2.xsl"));
- XMLFilter xmlFilter3 = saxTFactory.newXMLFilter(new
StreamSource("foo3.xsl"));
+ TransformerFactory tFactory = TransformerFactory.newInstance();
+ // Determine whether the TransformerFactory supports The use uf
SAXSource
+ // and SAXResult
+ if (tFactory.getFeature(SAXSource.FEATURE) &&
tFactory.getFeature(SAXResult.FEATURE))
+ {
+ // Cast the TransformerFactory to SAXTransformerFactory.
+ SAXTransformerFactory saxTFactory = ((SAXTransformerFactory) tFactory);
+ // Create an XMLFilter for each stylesheet.
+ XMLFilter xmlFilter1 = saxTFactory.newXMLFilter(new
StreamSource("foo1.xsl"));
+ XMLFilter xmlFilter2 = saxTFactory.newXMLFilter(new
StreamSource("foo2.xsl"));
+ XMLFilter xmlFilter3 = saxTFactory.newXMLFilter(new
StreamSource("foo3.xsl"));
- // Create an XMLReader (implemented by the Xerces SAXParser).
- XMLReader reader = XMLReaderFactory.createXMLReader();
+ // Create an XMLReader.
+ XMLReader reader = XMLReaderFactory.createXMLReader();
- // xmlFilter1 uses the reader (SAXParser) as its reader.
- xmlFilter1.setParent(reader);
+ // xmlFilter1 uses the XMLReader as its reader.
+ xmlFilter1.setParent(reader);
- // xmlFilter2 uses xmlFilter1 as its reader.
- xmlFilter2.setParent(xmlFilter1);
+ // xmlFilter2 uses xmlFilter1 as its reader.
+ xmlFilter2.setParent(xmlFilter1);
- // xmlFilter3 uses xmlFilter2 as its reader.
- xmlFilter3.setParent(xmlFilter2);
+ // xmlFilter3 uses xmlFilter2 as its reader.
+ xmlFilter3.setParent(xmlFilter2);
- // xmlFilter3 outputs SAX events to the serializer.
- Serializer serializer = SerializerFactory.getSerializer("xml");
- serializer.setOutputStream(System.out);
- xmlFilter3.setContentHandler(serializer.asContentHandler());
+ // xmlFilter3 outputs SAX events to the serializer.
+ Serializer serializer = SerializerFactory.getSerializer("xml");
+ serializer.setOutputStream(System.out);
+ xmlFilter3.setContentHandler(serializer.asContentHandler());
- // Perform the series of transformations as follows:
- // transformer3 gets its parent (transformer2) as the
XMLReader/XMLFilter
- // and calls transformer2.parse(new InputSource("foo.xml")).
- // transformer2 gets its parent (transformer1) as the
XMLReader/XMLFilter
- // and calls transformer1.parse(new InputSource("foo.xml")).
- // transformer1 gets its parent (reader, a SAXParser) as the XMLReader
- // and calls reader.parse(new InputSource("foo.xml")).
- // reader parses the XML document and sends the SAX parse events to
transformer1,
- // which performs transformation 1 and sends the output to
transformer2.
- // transformer2 parses the transformation 1 output, performs
transformation 2, and
- // sends the output to transformer3.
- // transformer3 parses the transformation 2 output, performs
transformation 3,
- // and sends the output to the serializer.
- xmlFilter3.parse(new InputSource("foo.xml"));
+ // Perform the series of transformations as follows:
+ // - transformer3 gets its parent (transformer2) as the
XMLReader/XMLFilter
+ // and calls transformer2.parse(new InputSource("foo.xml")).
+ // - transformer2 gets its parent (transformer1) as the
XMLReader/XMLFilter
+ // and calls transformer1.parse(new InputSource("foo.xml")).
+ // - transformer1 gets its parent (reader, a SAXParser) as the
XMLReader
+ // and calls reader.parse(new InputSource("foo.xml")).
+ // - reader parses the XML document and sends the SAX parse
events to transformer1,
+ // which performs transformation 1 and sends the output to
transformer2.
+ // - transformer2 parses the transformation 1 output, performs
transformation 2, and
+ // sends the output to transformer3.
+ // - transformer3 parses the transformation 2 output, performs
transformation 3,
+ // and sends the output to the serializer.
+ xmlFilter3.parse(new InputSource("foo.xml"));
+ }
}
}