cvs commit: jakarta-commons/jxpath/xdocs users-guide.xml

2003-03-24 Thread dmitri
dmitri  2003/03/24 18:41:35

  Modified:jxpath   project.xml
   jxpath/src/java/org/apache/commons/jxpath/ri
EvalContext.java JXPathContextReferenceImpl.java
   jxpath/src/java/org/apache/commons/jxpath/ri/axes
InitialContext.java PredicateContext.java
RootContext.java SimplePathInterpreter.java
UnionContext.java
   jxpath/src/java/org/apache/commons/jxpath/ri/compiler
ExpressionPath.java
   jxpath/src/java/org/apache/commons/jxpath/ri/model
NodePointer.java VariablePointer.java
   jxpath/src/java/org/apache/commons/jxpath/ri/model/beans
CollectionPointer.java PropertyIterator.java
   jxpath/src/java/org/apache/commons/jxpath/util
BasicTypeConverter.java
   jxpath/src/test/org/apache/commons/jxpath/ri/compiler
ExtensionFunctionTest.java TestFunctions.java
   jxpath/src/test/org/apache/commons/jxpath/ri/model
BeanModelTestCase.java
   jxpath/src/test/org/apache/commons/jxpath/util
BasicTypeConverterTest.java
   jxpath/xdocs users-guide.xml
  Added:   jxpath/src/java/org/apache/commons/jxpath BasicNodeSet.java
   jxpath/src/java/org/apache/commons/jxpath/ri/axes
NodeSetContext.java
   jxpath/src/java/org/apache/commons/jxpath/ri/model/beans
CollectionAttributeNodeIterator.java
CollectionChildNodeIterator.java
CollectionNodeIterator.java
   jxpath/src/test/org/apache/commons/jxpath/ri StressTest.java
  Log:
  Fixed collection as return value of extension function
  Reduced the amount of cloning
  
  Revision  ChangesPath
  1.13  +10 -10jakarta-commons/jxpath/project.xml
  
  Index: project.xml
  ===
  RCS file: /home/cvs/jakarta-commons/jxpath/project.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- project.xml   11 Mar 2003 00:59:10 -  1.12
  +++ project.xml   25 Mar 2003 02:41:33 -  1.13
  @@ -93,18 +93,18 @@
   
 reports
   reportmaven-junit-report-plugin/report
  -!--
  +
   reportmaven-jdepend-plugin/report
   reportmaven-checkstyle-plugin/report
  -reportmaven-changelog-plugin/report
  -reportmaven-developer-activity-plugin/report
  -reportmaven-file-activity-plugin/report
  -reportmaven-javadoc-plugin/report
  +!--reportmaven-changelog-plugin/report--
  +!--reportmaven-developer-activity-plugin/report--
  +!--reportmaven-file-activity-plugin/report--
  +!--reportmaven-javadoc-plugin/report--
   reportmaven-jxr-plugin/report
  -reportmaven-license-plugin/report
  -reportmaven-linkcheck-plugin/report
  -reportmaven-tasklist-plugin/report
  -reportmaven-clover-plugin/report
  ---
  +!--reportmaven-license-plugin/report--
  +!--reportmaven-linkcheck-plugin/report--
  +!--reportmaven-tasklist-plugin/report--
  +!--reportmaven-clover-plugin/report--
  +
 /reports
   /project
  
  
  
  1.1  
jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/BasicNodeSet.java
  
  Index: BasicNodeSet.java
  ===
  /*
   * $Header: 
/home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/BasicNodeSet.java,v
 1.1 2003/03/25 02:41:33 dmitri Exp $
   * $Revision: 1.1 $
   * $Date: 2003/03/25 02:41:33 $
   *
   * 
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *notice, this list of conditions and the following disclaimer in
   *the documentation and/or other materials provided with the
   *distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *any, must include the following acknowlegement:
   *   This product includes software developed by the
   *Apache Software Foundation (http://www.apache.org/).
   *Alternately, this acknowlegement may appear in the software itself,
   *if and wherever such third-party acknowlegements normally appear.
   *
   * 4. 

cvs commit: jakarta-commons/jxpath/xdocs users-guide.xml

2002-04-10 Thread dmitri

dmitri  02/04/10 20:00:32

  Modified:jxpath/xdocs users-guide.xml
  Log:
  Added more text
  
  Revision  ChangesPath
  1.2   +182 -74   jakarta-commons/jxpath/xdocs/users-guide.xml
  
  Index: users-guide.xml
  ===
  RCS file: /home/cvs/jakarta-commons/jxpath/xdocs/users-guide.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- users-guide.xml   10 Apr 2002 03:40:21 -  1.1
  +++ users-guide.xml   11 Apr 2002 03:00:31 -  1.2
  @@ -19,14 +19,17 @@
   p
If you are not familiar with the XPath syntax, start with
a href=http://www.w3schools.com/xpath;XPath Tutorial by W3Schools/a.br/
  - Also see a href=http://www.w3.org/TR/xpath;XML Path Language (XPath) 
Version 1.0 /a
  + Also see a href=http://www.w3.org/TR/xpath;XML Path Language (XPath) 
Version 1.0 /a -
  + that's the official standard.
   /p
   
   p
  - You can read and write properties
  - of JavaBeans, get and set elements of arrays, collections,
  - maps, DOM documents, transparent containers, various context objects
  - in Servlets etc.
  + XPath is the official expression language of XSLT. In XSLT you mostly use
  + XPath to access various elements of XML documents.  You can do that with
  + JXPath as well. In addition, you can read and write properties of JavaBeans, 
get and set
  + elements of arrays, collections, maps, transparent containers, various context 
objects
  + in Servlets etc.  In other words, JXPath applies the concepts of XPath
  + to alternate object models.
   /p
   
   p
  @@ -46,8 +49,9 @@
properties.
   /p
   p
  - The interpretation of the xpath syntax in the context of Java object graphs
  - is quite intuitive: the child axis of XPath is mapped to JavaBean properties.
  + The interpretation of the XPath syntax in the context of Java object graphs
  + is quite intuitive: the codechild/code axis of XPath is mapped to
  + JavaBean properties.
   /p
   
   subsection name=JavaBean Property Access
  @@ -71,11 +75,19 @@
   
   p
In this example, we are using JXPath to access a property of the 
codeemp/code bean.
  - In this simple case the invocation of JXPath is equivalent to invocation of 
getFirstName()
  - on the bean.
  + In this simple case the invocation of JXPath is equivalent to invocation of
  + codegetFirstName()/code on the bean.
   /p
   /subsection
   
  +subsection name=Lenient Mode
  +p
  +The codecontext.getValue(xpath)/code method throws an exception if the
  +supplied xpath does not map to an existing property.  This
  +constraint can be relaxed by calling codecontext.setLenient(true)/code.
  +In the lenient mode the method merely returns null if the path maps to nothing.
  +/p
  +/subsection
   
   subsection name=Nested Bean Property Access
p
  @@ -104,7 +116,7 @@
In this case XPath is used to access a property of a nested bean.
/p
p
  - A property identified by the xpath does not have to be a leaf property.
  + A property identified by the XPath does not have to be a leaf property.
For instance, we can extract the whole Address object in above example:
/p
source
  @@ -139,6 +151,30 @@
/p
   /subsection
   
  +subsection name=Retrieving Multiple Results
  + p
  + JXPath can retrieve multiple objects from a graph. Note that the method
  + called in this case is not codegetValue/code, but codeeval/code.
  + /p
  + source
  +   #xA0;
  + public class Author {
  +public Book[] getBooks(){
  +   ...
  +}
  + }
  +
  + Author auth = new Author();
  + ...
  +
  + JXPathContext context = JXPathContext.newContext(auth);
  + List threeBooks = (List)context.eval(books[position() lt; 4]);
  + /source
  + p
  + This returns a list of at most three books from the array of all books
  + written by the author.
  + /p
  +/subsection
   
   subsection name=Map Element Access
p
  @@ -147,21 +183,19 @@
source
  #xA0;
public class Employee {
  -public Map getAddresses(){
  -   return addressMap;
  +private Map addressMap = new HashMap();
  +{
  +addressMap.put(home, new Address(...));
  +addressMap.put(office, new Address(...));
   }
   
  -public void addAddress(String key, Address address){
  -   addressMap.put(key, address);
  +public Map getAddresses(){
  +   return addressMap;
   }
   ...
}
   
Employee emp = new Employee();
  - emp.addAddress(home, new Address(...));
  - emp.addAddress(office, new Address(...));
  - ...
  -
JXPathContext context = JXPathContext.newContext(emp);
String homeZipCode =
   (String)context.getValue(addresses/home/zipCode);
  @@ -177,11 +211,14