锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲中文无码a∨在线观看,大桥未久亚洲无av码在线 ,亚洲中文字幕在线观看http://www.tkk7.com/fine/category/14612.htmlzh-cnWed, 10 Oct 2007 15:23:56 GMTWed, 10 Oct 2007 15:23:56 GMT60xml涓巋tml緇撳悎http://www.tkk7.com/fine/archive/2007/10/10/151724.htmlPeter PanPeter PanWed, 10 Oct 2007 05:57:00 GMThttp://www.tkk7.com/fine/archive/2007/10/10/151724.htmlhttp://www.tkk7.com/fine/comments/151724.htmlhttp://www.tkk7.com/fine/archive/2007/10/10/151724.html#Feedback0http://www.tkk7.com/fine/comments/commentRss/151724.htmlhttp://www.tkk7.com/fine/services/trackbacks/151724.html

聽1 < XML聽ID = a >
聽2 < namelist >
聽3 聽聽聽聽 < names >
聽4 聽聽聽聽聽聽聽聽 < name > aaaa </ name >
聽5 聽聽聽聽 </ names >
聽6 聽聽聽聽 < names >
聽7 聽聽聽聽聽聽聽聽 < name > bbbb </ name >
聽8 聽聽聽聽 </ names >
聽9 </ namelist >
10 </ XML >
11
12 < DIV聽datasrc = #a聽datafld = name ></ DIV >
13
14 < TABLE聽border = 1 聽DATASRC = #a >
15 < TR >
16 < TD >< DIV聽DATAFLD = name ></ DIV ></ TD ></ TD >
17 </ TR >
18 </ TABLE >


Peter Pan 2007-10-10 13:57 鍙戣〃璇勮
]]>
Digester 鐨勪嬌鐢?http://www.tkk7.com/fine/archive/2006/08/29/66360.htmlPeter PanPeter PanTue, 29 Aug 2006 01:46:00 GMThttp://www.tkk7.com/fine/archive/2006/08/29/66360.htmlhttp://www.tkk7.com/fine/comments/66360.htmlhttp://www.tkk7.com/fine/archive/2006/08/29/66360.html#Feedback0http://www.tkk7.com/fine/comments/commentRss/66360.htmlhttp://www.tkk7.com/fine/services/trackbacks/66360.htmlBelow are brief descriptions of all of the standard rules.

Creational

  • ObjectCreateRule: Creates an object of the specified class using its default constructor and pushes it onto the stack; it is popped when the element completes. The class to instantiate can be given through a class object or the fully-qualified class name.

  • FactoryCreateRule: Creates an object using a specified factory class and pushes it onto the stack. This can be useful for classes that do not provide a default constructor. The factory class must implement the org.apache.commons.digester.ObjectCreationFactory interface.

Property Setters

  • SetPropertiesRule: Sets one or several named properties in the top-level bean using the values of named XML element attributes. Attribute names and property names are passed to this rule in String[] arrays. (Typically used to handle XML constructs like <article page="10">.)

  • BeanPropertySetterRule: Sets a named property on the top-level bean to the character data enclosed by the current XML element. (Example: <page>10</page>.)

  • SetPropertyRule: Sets a property on the top-level bean. Both the property name, as well as the value to which this property will be set, are given as attributes to the current XML element. (Example: <article key="page" value="10" />.)

Parent/Child Management

  • SetNextRule: Pops the object on top of the stack and passes it to a named method on the object immediately below. Typically used to insert a completed bean into its parent.

  • SetTopRule: Passes the second-to-top object on the stack to the top-level object. This is useful if the child object exposes a setParent method, rather than the other way around.

  • SetRootRule: Calls a method on the object at the bottom of the stack, passing the object on top of the stack as argument.

Arbitrary Method Calls

  • CallMethodRule: Calls an arbitrary named method on the top-level bean. The method may take an arbitrary set of parameters. The values of the parameters are given by subsequent applications of the CallParamRule.

  • CallParamRule: Represents the value of a method parameter. The value of the parameter is either taken from a named XML element attribute, or from the raw character data enclosed by the current element. This rule requires that its position on the parameter list is specified by an integer index.

Specifying Rules in XML: Using the xmlrules Package

So far, we have specified the patterns and rules programmatically at compile time. While conceptually simple and straightforward, this feels a bit odd: the entire framework is about recognizing and handling structure and data at run time, but here we go fixing the behavior at compile time! Large numbers of fixed strings in source code typically indicate that something is being configured (rather than programmed), which could be (and probably should be) done at run time instead.

The org.apache.commons.digester.xmlrules package addresses this issue. It provides the DigesterLoader class, which reads the pattern/rule-pairs from an XML document and returns a digester already configured accordingly. The XML document configuring the Digester must comply with the digester-rules.dtd, which is part of the xmlrules package.

Below is the contents of the configuration file (named rules.xml) for the example application. I want to point out several things here.

Patterns can be specified in two different ways: either as attributes to each XML element representing a rule, or using the <pattern> element. The pattern defined by the latter is valid for all contained rule elements. Both ways can be mixed, and <pattern> elements can be nested -- in either case, the pattern defined by the child element is appended to the pattern defined in the enclosing <pattern> element.

The <alias> element is used with the <set-properties-rule> to map an XML attribute to a bean property.

Finally, using the current release of the Digester package, it is not possible to specify the BeanPropertySetterRule in the configuration file. Instead, we are using the CallMethodRule to achieve the same effect, as explained above.

				<?xml version="1.0"?>

<digester-rules>
   <object-create-rule pattern="catalog" classname="Catalog" />
   <set-properties-rule pattern="catalog" >
      <alias attr-name="library" prop-name="library" />
   </set-properties-rule>

   <pattern value="catalog/book">
      <object-create-rule classname="Book" />
      <call-method-rule pattern="author" methodname="setAuthor"
	                paramcount="0" />
      <call-method-rule pattern="title" methodname="setTitle" 
	                paramcount="0" />
      <set-next-rule methodname="addBook" />
   </pattern>

   <pattern value="catalog/magazine">
      <object-create-rule classname="Magazine" />

      <call-method-rule pattern="name" methodname="setName" paramcount="0" />

      <pattern value="article">
         <object-create-rule classname="Article" />
         <set-properties-rule>
            <alias attr-name="page" prop-name="page" />
         </set-properties-rule>    
         <call-method-rule pattern="headline" methodname="setHeadline" 
		           paramcount="0" />
         <set-next-rule methodname="addArticle" />
      </pattern>

      <set-next-rule methodname="addMagazine" /> 
   </pattern>
</digester-rules>
		

Since all the actual work has now been delegated to the Digester and DigesterLoader classes, the driver class itself becomes trivially simple. To run it, specify the catalog document as the first command line argument, and the rules.xml file as the second. (Confusingly, the DigesterLoader will not read the rules.xml file from a File or an org.xml.sax.InputSource, but requires a URL -- the File reference in the code below is therefore transformed into an equivalent URL.)

				import org.apache.commons.digester.*;
import org.apache.commons.digester.xmlrules.*;

import java.io.*;
import java.util.*;

public class XmlRulesDriver {
   public static void main( String[] args ) {
      try {

         File input = new File( args[0] );
         File rules = new File( args[1] );

         Digester digester = DigesterLoader.createDigester( rules.toURL() );

         Catalog catalog = (Catalog)digester.parse( input );
         System.out.println( catalog.toString() );
  
      } catch( Exception exc ) {
         exc.printStackTrace();
      }
   }
}
		


Peter Pan 2006-08-29 09:46 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 四虎永久在线观看免费网站网址| 国产一二三四区乱码免费| 久久成人免费大片| 亚洲欧洲无码AV电影在线观看| 天堂亚洲免费视频| 亚洲国产一区明星换脸| 一级日本高清视频免费观看| 亚洲成网777777国产精品| 成人午夜免费视频| 中文字幕第13亚洲另类| 四虎国产精品免费永久在线| 亚洲国产精品成人精品无码区在线| 精品人妻系列无码人妻免费视频 | 亚洲精品一级无码中文字幕| 亚洲av第一网站久章草| yy6080久久亚洲精品| 日日躁狠狠躁狠狠爱免费视频| 亚洲伊人久久综合中文成人网| 免费看黄的成人APP| 亚洲av日韩av不卡在线观看| 最近免费中文字幕大全免费 | 四虎1515hh永久久免费| 亚洲AV无码一区二区三区在线| 毛片免费观看的视频| 午夜亚洲国产精品福利| 亚洲色成人中文字幕网站| 国产激情免费视频在线观看| 亚洲午夜电影在线观看| 国产精品另类激情久久久免费| 一级人做人a爰免费视频| 亚洲电影中文字幕| 久久久久国色AV免费观看性色 | 久久久久亚洲AV无码去区首| 中文字幕亚洲天堂| 84pao国产成视频免费播放| 亚洲另类无码专区首页| 亚洲一区二区三区AV无码 | 日本人护士免费xxxx视频| 好猛好深好爽好硬免费视频| 亚洲高清日韩精品第一区| 国产高清在线免费视频|