OT Digester question

2003-08-04 Thread Jim Collins
Appologies for the off topic question. Does anyone know how I can create an
object with a constructor that takes agruments specified via XML elements.

I have a Configuration object with a constructor that takes two String
parameters. The XML will be something like this:

config
param1someText/param1
param2someText/param2
saveAssomeText/savaAs
/config

When the digester matches the config pattern it will create the
Configuration object passing param1 and param2 as parameters to the
constructor and then when it matches the pattern config/saveAs it will call
a method on the Configuration object.

I have looked at the documentation and have seen the FactoryCreateRule but I
am not sure how to use this and how I can get it to use the param1 and
param2 elements as the Constructor parameters.

Once again sorry for the off topic post. Any hints would be appreciated.

Thanks

Jim.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] Digester question

2003-08-04 Thread Kris Schneider
A bit out of my comfort zone on this one, but I think you might have to change
your XML to something like:

config attr1=someText attr2=someText
  saveAssomeText/savaAs
/config

because the FactoryCreateRule/ObjectCreationFactory stuff seems to work with an
element's attributes, not its sub-elements. Then it looks like you need to
subclass AbstractObjectCreationFactory and provode a createObject method impl
that will extract the appropriate attribute values and construct your
Configuration object. I'm sure other folks on the list (or on commons-user) have
more experience with this though...

Quoting Jim Collins [EMAIL PROTECTED]:

 Appologies for the off topic question. Does anyone know how I can create an
 object with a constructor that takes agruments specified via XML elements.
 
 I have a Configuration object with a constructor that takes two String
 parameters. The XML will be something like this:
 
 config
 param1someText/param1
 param2someText/param2
 saveAssomeText/savaAs
 /config
 
 When the digester matches the config pattern it will create the
 Configuration object passing param1 and param2 as parameters to the
 constructor and then when it matches the pattern config/saveAs it will call
 a method on the Configuration object.
 
 I have looked at the documentation and have seen the FactoryCreateRule but
 I
 am not sure how to use this and how I can get it to use the param1 and
 param2 elements as the Constructor parameters.
 
 Once again sorry for the off topic post. Any hints would be appreciated.
 
 Thanks
 
 Jim.

-- 
Kris Schneider mailto:[EMAIL PROTECTED]
D.O.Tech   http://www.dotech.com/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] Digester question

2003-08-04 Thread Jim Collins
Kris,

Thanks for the help.

Jim.
- Original Message -
From: Kris Schneider [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Monday, August 04, 2003 8:46 PM
Subject: Re: [OT] Digester question


 A bit out of my comfort zone on this one, but I think you might have to
change
 your XML to something like:

 config attr1=someText attr2=someText
   saveAssomeText/savaAs
 /config

 because the FactoryCreateRule/ObjectCreationFactory stuff seems to work
with an
 element's attributes, not its sub-elements. Then it looks like you need to
 subclass AbstractObjectCreationFactory and provode a createObject method
impl
 that will extract the appropriate attribute values and construct your
 Configuration object. I'm sure other folks on the list (or on
commons-user) have
 more experience with this though...

 Quoting Jim Collins [EMAIL PROTECTED]:

  Appologies for the off topic question. Does anyone know how I can create
an
  object with a constructor that takes agruments specified via XML
elements.
 
  I have a Configuration object with a constructor that takes two String
  parameters. The XML will be something like this:
 
  config
  param1someText/param1
  param2someText/param2
  saveAssomeText/savaAs
  /config
 
  When the digester matches the config pattern it will create the
  Configuration object passing param1 and param2 as parameters to the
  constructor and then when it matches the pattern config/saveAs it will
call
  a method on the Configuration object.
 
  I have looked at the documentation and have seen the FactoryCreateRule
but
  I
  am not sure how to use this and how I can get it to use the param1 and
  param2 elements as the Constructor parameters.
 
  Once again sorry for the off topic post. Any hints would be appreciated.
 
  Thanks
 
  Jim.

 --
 Kris Schneider mailto:[EMAIL PROTECTED]
 D.O.Tech   http://www.dotech.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]



Re: [OT] Digester question

2003-08-04 Thread Kris Schneider
Um, so, that actually worked? ;-)

Quoting Jim Collins [EMAIL PROTECTED]:

 Kris,
 
 Thanks for the help.
 
 Jim.
 - Original Message -
 From: Kris Schneider [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Sent: Monday, August 04, 2003 8:46 PM
 Subject: Re: [OT] Digester question
 
 
  A bit out of my comfort zone on this one, but I think you might have to
 change
  your XML to something like:
 
  config attr1=someText attr2=someText
saveAssomeText/savaAs
  /config
 
  because the FactoryCreateRule/ObjectCreationFactory stuff seems to work
 with an
  element's attributes, not its sub-elements. Then it looks like you need
 to
  subclass AbstractObjectCreationFactory and provode a createObject method
 impl
  that will extract the appropriate attribute values and construct your
  Configuration object. I'm sure other folks on the list (or on
 commons-user) have
  more experience with this though...
 
  Quoting Jim Collins [EMAIL PROTECTED]:
 
   Appologies for the off topic question. Does anyone know how I can
 create
 an
   object with a constructor that takes agruments specified via XML
 elements.
  
   I have a Configuration object with a constructor that takes two String
   parameters. The XML will be something like this:
  
   config
   param1someText/param1
   param2someText/param2
   saveAssomeText/savaAs
   /config
  
   When the digester matches the config pattern it will create the
   Configuration object passing param1 and param2 as parameters to the
   constructor and then when it matches the pattern config/saveAs it will
 call
   a method on the Configuration object.
  
   I have looked at the documentation and have seen the FactoryCreateRule
 but
   I
   am not sure how to use this and how I can get it to use the param1 and
   param2 elements as the Constructor parameters.
  
   Once again sorry for the off topic post. Any hints would be
 appreciated.
  
   Thanks
  
   Jim.
 
  --
  Kris Schneider mailto:[EMAIL PROTECTED]
  D.O.Tech   http://www.dotech.com/

-- 
Kris Schneider mailto:[EMAIL PROTECTED]
D.O.Tech   http://www.dotech.com/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] Digester question

2003-08-04 Thread Jim Collins
I haven't got it to work yet but you confirmed what I thought about not
being able to use nested tags and having to use attributes instead. I am
just checking out now how to use the FactoryCreateRule.

Jim.
- Original Message -
From: Kris Schneider [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Monday, August 04, 2003 9:06 PM
Subject: Re: [OT] Digester question


 Um, so, that actually worked? ;-)

 Quoting Jim Collins [EMAIL PROTECTED]:

  Kris,
 
  Thanks for the help.
 
  Jim.
  - Original Message -
  From: Kris Schneider [EMAIL PROTECTED]
  To: Struts Users Mailing List [EMAIL PROTECTED]
  Sent: Monday, August 04, 2003 8:46 PM
  Subject: Re: [OT] Digester question
 
 
   A bit out of my comfort zone on this one, but I think you might have
to
  change
   your XML to something like:
  
   config attr1=someText attr2=someText
 saveAssomeText/savaAs
   /config
  
   because the FactoryCreateRule/ObjectCreationFactory stuff seems to
work
  with an
   element's attributes, not its sub-elements. Then it looks like you
need
  to
   subclass AbstractObjectCreationFactory and provode a createObject
method
  impl
   that will extract the appropriate attribute values and construct your
   Configuration object. I'm sure other folks on the list (or on
  commons-user) have
   more experience with this though...
  
   Quoting Jim Collins [EMAIL PROTECTED]:
  
Appologies for the off topic question. Does anyone know how I can
  create
  an
object with a constructor that takes agruments specified via XML
  elements.
   
I have a Configuration object with a constructor that takes two
String
parameters. The XML will be something like this:
   
config
param1someText/param1
param2someText/param2
saveAssomeText/savaAs
/config
   
When the digester matches the config pattern it will create the
Configuration object passing param1 and param2 as parameters to the
constructor and then when it matches the pattern config/saveAs it
will
  call
a method on the Configuration object.
   
I have looked at the documentation and have seen the
FactoryCreateRule
  but
I
am not sure how to use this and how I can get it to use the param1
and
param2 elements as the Constructor parameters.
   
Once again sorry for the off topic post. Any hints would be
  appreciated.
   
Thanks
   
Jim.
  
   --
   Kris Schneider mailto:[EMAIL PROTECTED]
   D.O.Tech   http://www.dotech.com/

 --
 Kris Schneider mailto:[EMAIL PROTECTED]
 D.O.Tech   http://www.dotech.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]



Struts Digester question...

2002-06-10 Thread @Basebeans.com

Subject: Struts Digester question...
From: Scott Curtis [EMAIL PROTECTED]
 ===
Hi,

When I start my server and Struts loads I am seeing the following line in
the console:

register('-//Apache Software Foundation//DTD Struts Configuration 1.0//EN',
'classloader:/org/apache/struts/resources/struts-config_1_0.dtd'

I am not 100% sure what this is doing which is the first problem. I guess it
is somehow adding the DTD to the classpath so that it is accessible from
within xml files using the dtd name (struts-config_1_0.dtd) rather than a
full path/URL to the dtd file.

I would like to add my own DTD in a similar way so that xml files that I
pass into the system can access it by it's name and not require a full path
to the dtd file. If the above line of code doesn't do what I have suggested
is there a way to add a DTD in the manner I have suggested so that the xml
files to be validated against it can reference it by it's name only and not
the full URL/path?

Hope that makes some sense to someone out there! :-)

Thanks
 - scott



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Struts Digester question...

2002-06-10 Thread Craig R. McClanahan

On Mon, 10 Jun 2002, Struts Newsgroup wrote:

 Date: Mon, 10 Jun 2002 01:10:02 -0700
 From: Struts Newsgroup [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: Struts Digester question...

 Subject: Struts Digester question...
 From: Scott Curtis [EMAIL PROTECTED]
  ===
 Hi,

 When I start my server and Struts loads I am seeing the following line in
 the console:

 register('-//Apache Software Foundation//DTD Struts Configuration 1.0//EN',
 'classloader:/org/apache/struts/resources/struts-config_1_0.dtd'

 I am not 100% sure what this is doing which is the first problem. I guess it
 is somehow adding the DTD to the classpath so that it is accessible from
 within xml files using the dtd name (struts-config_1_0.dtd) rather than a
 full path/URL to the dtd file.

 I would like to add my own DTD in a similar way so that xml files that I
 pass into the system can access it by it's name and not require a full path
 to the dtd file. If the above line of code doesn't do what I have suggested
 is there a way to add a DTD in the manner I have suggested so that the xml
 files to be validated against it can reference it by it's name only and not
 the full URL/path?

 Hope that makes some sense to someone out there! :-)


If you look inside Digester, you will find that that it uses a SAX parser,
via the JAXP APIs.  SAX lets you register an EntityHandler object that
is called during the parse when a !DOCTYPE is encountered.  As you might
surmize, the registration noted by the log message is telling Digester
whenever you see the public identifier of the Struts configuration file
DTD, use this copy instead of going out to the Internet.

The important issue, though, is where the second URL came from -- if the
resource is inside your webapp, you *must* ask your servlet container for
the URL of the requested resource.  There are two basic options:

(1) Resource file somewhere within your webapp (i.e. /WEB-INF/mydtd.dtd)

Digester digester = ...;
digester.register(... public id for my DTD ...,
  context.getResource(/WEB-INF/mydtd.dtd).toString());

(2) Resource file somewhere in the class path (this is what Struts
does ... the DTD it is loading is in the org/apache/struts/resources
package in struts.jar):

Digester digester = ...;
URL url = this.getClass().getResource(/path/to/mydtd.dtd);
digester.register(... public id for my DTD ...,
   url.toString());

As long as your XML documents have a DOCTYPE with a public identifier that
matches the first argument to the register() method, then the XML parser
will use the URL passed as the second argument to retrieve the DTD,
instead of paying attention to any system identifier in the DOCTYPE.


 Thanks
  - scott


Craig


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Digester Question

2002-03-05 Thread Craig Tataryn

Anyone?

/tataryn:craig

From: Craig Tataryn [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Digester Question
Date: Mon, 04 Mar 2002 14:19:07 -0600

I realize that the digester is now part of commons, but I figure there is
probably a lot of expertise here since it grew up in Struts.  I was
wondering if someone could help me figure out the easiest way to do this:

I have an xml document, that holds form data, I would like to use the
digester to populate my objects automatically.  A form file might look like
this:

forms
  form type=shopping-cart
 
  /form
  form type=calculator
  ...
  /form
...
/forms

Let's assume there are many forms...  I was wondering, without having to
load all forms into objects and then picking the one I want to use, I would
rather the digester only instantiate and populate an object for lets say,
the form node who's type attribute is calculator.

What's the easiest way to do this?  I don't think the digester can pattern
match on attribute values the way XPath does, so is there a programming
technique I can use to filter further?

Thanks,

Craig.

Craig W. Tataryn
Programmer/Analyst
Compuware

_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


--
To unsubscribe, e-mail:   
mailto:[EMAIL PROTECTED]
For additional commands, e-mail: 
mailto:[EMAIL PROTECTED]



Craig W. Tataryn
Programmer/Analyst
Compuware

_
Send and receive Hotmail on your mobile device: http://mobile.msn.com


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Digester Question

2002-03-05 Thread Steve A Drake

On Mon, 4 Mar 2002, Craig Tataryn wrote:

 I realize that the digester is now part of commons, but I figure there is
 probably a lot of expertise here since it grew up in Struts.  I was
 wondering if someone could help me figure out the easiest way to do this:

 I have an xml document, that holds form data, I would like to use the
 digester to populate my objects automatically.  A form file might look like
 this:

 forms
   form type=shopping-cart
  
   /form
   form type=calculator
   ...
   /form
 ...
 /forms

 Let's assume there are many forms...  I was wondering, without having to
 load all forms into objects and then picking the one I want to use, I would
 rather the digester only instantiate and populate an object for lets say,
 the form node who's type attribute is calculator.

 What's the easiest way to do this?  I don't think the digester can pattern
 match on attribute values the way XPath does, so is there a programming
 technique I can use to filter further?

 Hi Craig. Since, AFAIK, the digester blindly instantiates all of the
implied objects in your database file, I think that you'll need to parse the
database file independently. You might try parsing the database file
using JDOM, extracting the elements that you want and passing that
snippet to the digester. I think that utilizing JDOM, you'll get working
code much faster than you would with raw SAX parsing. I have used
JDOM but I haven't tried utilizing it with the digester - just an idea.


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Digester Question

2002-03-04 Thread Craig Tataryn

I realize that the digester is now part of commons, but I figure there is 
probably a lot of expertise here since it grew up in Struts.  I was 
wondering if someone could help me figure out the easiest way to do this:

I have an xml document, that holds form data, I would like to use the 
digester to populate my objects automatically.  A form file might look like 
this:

forms
  form type=shopping-cart
 
  /form
  form type=calculator
  ...
  /form
...
/forms

Let's assume there are many forms...  I was wondering, without having to 
load all forms into objects and then picking the one I want to use, I would 
rather the digester only instantiate and populate an object for lets say, 
the form node who's type attribute is calculator.

What's the easiest way to do this?  I don't think the digester can pattern 
match on attribute values the way XPath does, so is there a programming 
technique I can use to filter further?

Thanks,

Craig.

Craig W. Tataryn
Programmer/Analyst
Compuware

_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: digester question

2001-02-16 Thread Craig R. McClanahan

"Gogineni, Pratima" wrote:

 Hi,

 I have been reading the documentation on digester - I was wondering if it
 uses XPATH for element pattern matching and if it doesnt why not?

 I dont think the documentation mentions this ...


That's *usually* a pretty good sign that it doesn't support the feature you
are looking for :-).

Currently, Digester uses a very simple pattern matching algorithm based on
the set of nested elements you are currently processing.  This seemed more
appropriate to the types of problems that Digester was created to solve (like
reading configuration files, or building arbitrary object trees).  However,
XPATH is something that might be interesting to consider for the future.

We're also going to look at XPATH as a way for the Struts custom tags to
access bean properties or navigate DOM objects in the presentation layer.


 THanks
 Pratima

Craig