You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by dl...@locus.apache.org on 2000/09/20 16:01:21 UTC

cvs commit: xml-xalan/java/xdocs/sources/xalan samples.xml usagepatterns.xml

dleslie     00/09/20 07:01:21

  Modified:    java/xdocs/sources/xalan samples.xml usagepatterns.xml
  Log:
  Added introductory info on XPathAPI and the ApplyXPath sample.
  
  Revision  Changes    Path
  1.5       +18 -0     xml-xalan/java/xdocs/sources/xalan/samples.xml
  
  Index: samples.xml
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/xdocs/sources/xalan/samples.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- samples.xml	2000/09/19 12:52:37	1.4
  +++ samples.xml	2000/09/20 14:01:21	1.5
  @@ -63,6 +63,7 @@
   <li><link anchor="usestylesheetparam">UseStylesheetParam</link></li>
   <li><link anchor="sax2sax">SAX2SAX</link></li>
   <li><link anchor="pipe">Pipe</link></li>
  +<li><link anchor="applyxpath">ApplyXPath</link></li>
   <li><link anchor="appletxmltohtml">AppletXMLtoHTML</link></li>
   <li><link anchor="servlet">Servlet</link></li>
   <li><link anchor="extensions">Extensions</link></li>
  @@ -121,6 +122,23 @@
         another. Each Transformer operates as a SAX2 XMLFilter/XMLReader.</p>
       <p>Run this sample from the Pipe subdirectory with</p> 
       <p><code>java Pipe</code></p>
  +    </s2><anchor name="applyxpath"/>
  +    <s2 title="ApplyXPath">
  +    <p>What it does: ApplyXPath uses the <jump href="apidocs/org/apache/xpath/XPathAPI.html">XPathAPI</jump> convenience methods to
  +    execute an XPath expression against an XML document and return the nodes (if any) it finds.</p>
  +     <note>You can use this sample as an aid when you want to find out what a given XPath expression returns from a
  +     given XML file. Keep in mind that the context node (base point of evaluation) for the XPath expression is the document
  +     root.</note>
  +    <p>Run this sample from the ApplyXPath subdirectory with</p> 
  +    <p><code>java ApplyXPath <ref>XMLFile XPathExpression</ref></code></p>
  +    <p>where <ref>XMLFile</ref> is an XML source file and <ref>XPathExpression</ref> is an XPath expression to
  +     apply to that file. The ApplyXPath subdirectory contains an XML file named foo.xml --<br/>
  +     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;doc&gt;&lt;name first="David" last="Marston"/&gt;...&lt;/doc></code><br/> -- so you can try command
  +     lines like</p>
  +    <p><code>java ApplyXPath foo.xml /</code></p>
  +    <p>and</p>
  +    <p><code>java ApplyXPath foo.xml /doc/name/@first</code></p>
  +    <p>For more information, see <link idref="usagepatterns" anchor="xpath">Working with XPath expressions</link>.</p>
       </s2><anchor name="appletxmltohtml"/>
       <s2 title="AppletXMLtoHTML">
       <p>The applet uses a stylesheet to transform an XML document into HTML. It displays the XML document, the
  
  
  
  1.3       +4 -2      xml-xalan/java/xdocs/sources/xalan/usagepatterns.xml
  
  Index: usagepatterns.xml
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/xdocs/sources/xalan/usagepatterns.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- usagepatterns.xml	2000/09/19 12:52:37	1.2
  +++ usagepatterns.xml	2000/09/20 14:01:21	1.3
  @@ -1,4 +1,4 @@
  --<?xml version="1.0" standalone="no"?> 
  +<?xml version="1.0" standalone="no"?> 
   <!DOCTYPE s1 SYSTEM "sbk:/style/dtd/document.dtd">
   <!--
    * The Apache Software License, Version 1.1
  @@ -202,7 +202,9 @@
   <note>If you are using the Xerces implementation of the <ref>Java API for XML Parsing</ref> (in xerces.jar), the default value for the javax.xml.parsers.DocumentBuilderFactory system property is org.apache.xerces.jaxp.DocumentBuilderFactoryImpl. The Xerces implementations of DocumentBuilder and DOM Document are org.apache.xerces.jaxp.DocumentBuilderImpl and org.apache.xerces.dom.DocumentImpl.</note>
   </s2><anchor name="xpath"/>
   <s2 title="Working with XPath expressions">
  -<p><ref>To be written.</ref></p>
  +<p>XSLT stylesheets use XPath expressions to select nodes, specify conditions, and generate text for the result tree. XPath provides an API that you can call directly. For example, you may want to select nodes programmatically and do your own processing without a stylesheet.</p>
  +<p>XPath is an independent entity, with clients other than XSLT processors (such as XPointer). Accordingly, &xslt4j2; has packaged XPath as a separate module (org.apache.xpath and its subpackages), although this module does use some utility classes packaged in org.apache.xalan.utils. The org.apache.xpath.XPathAPI class contains convenience methods that you can use to return single DOM Nodes, NodeIterators, and XObjects. Apart from their own functionality, these methods also provide a path into the lower-level XPath API that you may find useful.</p>
  +<p>For an example that uses the XPathAPI convenience methods to execute XPath expressions against XML source files, see <link idref="samples" anchor="applyxpath">ApplyXPath</link>.</p>
   </s2><anchor name="applet"/>
   <s2 title="Using the &xslt4j; applet wrapper">
   <ol>