Hi,
It would be appreciated if you could follow these conventions:
(1) Please do not use all-capitals for an email subject. IT IS ANNOYING AND
HARD TO READ.
(2) When using the commons list, put the component name at the start of the
subject line, eg
[digester] ... because this email list is shared by many components.
(3) Please try to choose a better subject for emails. About 50% of all emails
about digester could be described by this subject (the others can be described
as "rules api problem"). This subject is therefore no use to anyone searching
the archives.
I think you've just got a simple typing error. There is no "paramnumber"
attribute on call-method-rule. But using paramcount=0 should work (as you do
earlier in the file).
This also looks like a spelling mistake (well, in English anyway..):
<set-next-rule methodename="addLang" />
Everything else looks ok to me..
Regards,
Simon
---- twathelet <[EMAIL PROTECTED]> schrieb:
>
> High I'm using DIGESTER to parse an xml doc but it seems that I don't
> understang somethig
> My xml file:
>
> <!-- message JMS -->
> <message>
> <!-- enveloppe des informations propre la FDR -->
> <fdr>
> <!-- Numro de FDR (ex: 650451) -->
> <number>690504</number>
> <docType>
> <!-- Mnmonique du type de document (ex: AM, RR, ...) -->
> <docTypeMnemo>AM</docTypeMnemo>
> </docType>
> </fdr>
> <version>
> <!-- Indique l'outil utilis pour produire le doc. -->
> <jobProductionTool>SEIAMD</jobProductionTool>
> <!-- Donne toutes les langues cibles de la traduction ou de la
> mise en
> forme -->
> <languagesCouples>
> <languageCouple>
> <targetLanguage>EN</targetLanguage>
> </languageCouple>
> <languageCouple>
> <targetLanguage>FR</targetLanguage>
> </languageCouple>
> <languageCouple>
> <targetLanguage>DE</targetLanguage>
> </languageCouple>
> </languagesCouples>
> </version>
> </message>
>
> ***************************************************************
>
> My xml rules:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <digester-rules>
> <pattern value="message">
> <object-create-rule
> classname="europarl.trad.sild.movearch.model.FdrFile" />
> <call-method-rule pattern="fdr/number" methodname="setFdrNumber"
> paramcount="0" />
> <call-method-rule pattern="fdr/docType/docTypeMnemo"
> methodname="setDocType" paramcount="0" />
> <call-method-rule pattern="version/jobProductionTool"
> methodname="setProductionTool" paramcount="0" />
> <pattern
> value="message/version/languagesCouples/languageCouple">
> <object-create-rule
>
> classname="europarl.trad.sild.movearch.model.Lang" />
> <call-method-rule pattern="targetLanguage"
> methodname="setCode" paramnumber="0" />
> <call-method-rule pattern="targetLanguage"
> methodname="setLabel" paramnumber="0" />
> <set-next-rule methodename="addLang" />
> </pattern>
> </pattern>
> </digester-rules>
>
> ********************************************************************
>
> My classes are:
>
> /**
> *
> */
> package europarl.trad.sild.movearch.model;
>
> import java.util.Vector;
>
> /**
> * @author twathelet
> */
> public class FdrFile {
>
> private String fdrNumber;
>
> private String docType;
>
> private String productionTool;
>
> private Vector coupleLang;
>
> /**
> * @return the coupleLang
> */
> public Vector getCoupleLang() {
> return coupleLang;
> }
>
> /**
> * @param coupleLang
> * the coupleLang to set
> */
> public void setCoupleLang(Vector coupleLang) {
> this.coupleLang = coupleLang;
> }
>
> /**
> * @return the fdrNumber
> */
> public String getFdrNumber() {
> return fdrNumber;
> }
>
> /**
> * @param fdrNumber
> * the fdrNumber to set
> */
> public void setFdrNumber(String fdrNumber) {
> this.fdrNumber = fdrNumber;
> }
>
> /**
> * @return the docType
> */
> public String getDocType() {
> return docType;
> }
>
> /**
> * @param docType
> * the docType to set
> */
> public void setDocType(String docType) {
> this.docType = docType;
> }
>
> /**
> * @return the productionTool
> */
> public String getProductionTool() {
> return productionTool;
> }
>
> /**
> * @param productionTool
> * the productionTool to set
> */
> public void setProductionTool(String productionTool) {
> this.productionTool = productionTool;
> }
>
> public void addLang(Lang lang) {
> this.coupleLang.addElement(lang);
> }
>
> /**
> *
> */
> public FdrFile() {
> this.coupleLang = new Vector();
> }
>
> }
>
> ****************************************************
>
> /**
> *
> */
> package europarl.trad.sild.movearch.model;
>
> /**
> * @author twathelet
> */
> public class Lang {
> private String code;
>
> private String label;
>
> /**
> * @return the code
> */
> public String getCode() {
> return code;
> }
>
> /**
> * @param code
> * the code to set
> */
> public void setCode(String code) {
> this.code = code;
> }
>
> /**
> * @return the label
> */
> public String getLabel() {
> return label;
> }
>
> /**
> * @param label
> * the label to set
> */
> public void setLabel(String label) {
> this.label = label;
> }
>
> /**
> *
> */
> public Lang() {
> // TODO Auto-generated constructor stub
> }
>
> /**
> * @param code
> * @param label
> */
> public Lang(String code, String label) {
> super();
> this.code = code;
> this.label = label;
> }
>
> /**
> * @param code
> */
> public Lang(String code) {
> super();
> this.code = code;
> }
>
>
> }
>
>
> **********************************************************
>
> /**
> *
> */
> package europarl.trad.sild.movearch;
>
> import java.io.IOException;
> import java.io.InputStream;
>
> import org.apache.commons.digester.Digester;
> import org.apache.commons.digester.xmlrules.DigesterLoader;
> import org.xml.sax.InputSource;
> import org.xml.sax.SAXException;
>
> import europarl.trad.sild.movearch.model.FdrFile;
>
> /**
> * @author twathelet
> */
> public class Executable {
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> InputStream message =
> ClassLoader.getSystemClassLoader().getResourceAsStream(args[0]);
> InputSource configFile = new
> InputSource(ClassLoader.getSystemClassLoader().getResourceAsStream(args[1]));
> Digester d = DigesterLoader.createDigester(configFile);
> FdrFile fdrFile = new FdrFile();
> try {
> fdrFile = (FdrFile) d.parse(message);
> } catch (IOException e) {
> e.printStackTrace();
> } catch (SAXException e) {
> e.printStackTrace();
> }
> System.out.println(fdrFile.getFdrNumber());
> System.out.println(fdrFile.getDocType());
> System.out.println(fdrFile.getProductionTool());
> System.out.println(fdrFile.getCoupleLang().size());
> }
>
> }
>
> ********************************************************
>
> And when I execute the code I recive that
> 690504
> AM
> SEIAMD
> 0
>
> my question his why the number of language=0???
> Thanks
>
>
>
> --
> View this message in context:
> http://www.nabble.com/Re%3A-JAKARTA-COMMONS-DIGESTER-RULES-XML-PROBLEM-tp13500277p14251258.html
> Sent from the Commons - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]