Tammo,

This might be some bug. What Cocoon version do you have? Is it 2.0.3?

Can you make test case against 2.0.3 demo sitemap, default install, and
have your action to pull some cocoon:// source from the demo webapp
(cocoon source is also SAX based)?

Vadim


> From: Tammo van Lessen [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 23, 2002 7:12 AM
> To: [EMAIL PROTECTED]
> Subject: AW: parse generated xml and react in sitemap (Problem with
> AbstractSAXSource)
> 
> | Von: Vadim Gritsenko [mailto:[EMAIL PROTECTED]]
> |
> |
> | Using action. Write your action which reads this <file/> fragment
into
> | DOM/SAX, extracts <storepath>, <origname>, <mimetype> and returns
these
> | values in the Map to the sitemap.
> |
> | Then, pass these values to the regular reader.
> |
> |
> | Vadim
> |
> 
> Hello Vadim,
>   thanx for your answer. I tried this, but I had some strange trouble.
I
> wrote my own Action and called it in the sitemap like this:
> 
>           <map:act type="docprop"
>
src="xmldb:xindice://localhost:4080/db/gizmo/documents/#//document[@id=&
apos
> ;{1}&apos;]">
> 
> My action has the method act as follows:
> 
>     public Map act(Redirector redirector, SourceResolver resolver,
>                    Map objectModel, String source, Parameters par)
>             throws Exception {
> 
>         Source src = null;
>         HashMap actionMap = new HashMap();
>         try {
>             src = resolver.resolve(source);
>             String systemID = src.getSystemId();
>             if (this.getLogger().isDebugEnabled()) {
>                 getLogger().debug("docprop source [" + source + "]");
>                 getLogger().debug("docprop resolved to [" + systemID +
"]");
>             }
>               // this all works fine...
>               // but...
>             Parser parser = (Parser)this.manager.lookup(Parser.ROLE);
>               // src.getInputSource() raises an exception!
>               Document sdoc =
parser.parseDocument(src.getInputSource());
>               NodeList nl = sdoc.getElementsByTagName("document");
>               [...]
> 
> I got an exception from AbstractSAXSource.getInputStream...
> 
> org.apache.cocoon.ProcessingException: could not lookup pipeline
components:
> org.apache.avalon.framework.component.ComponentException:
UnnamedSelector:
> ComponentSelector could not find the component for hint: xml
>       at
>
org.apache.cocoon.components.source.AbstractSAXSource.getInputStream(Abs
trac
> tSAXSource.java:133)
>       at
>
org.apache.cocoon.components.source.AbstractSAXSource.getInputSource(Abs
trac
> tSAXSource.java:151)
>       at
>
de.taval.gizmo.acting.DocumentPropertyAction.act(DocumentPropertyAction.
java
> :116)
> 
> With other sources than the saxbased xmldbsource, it works fine.
> 
> Then I've copied the code of AbstractSAXSource.getInputStream and
> AbstractSAXSource.getInputSource into my action and it works properly.
But I
> dont understand why, and this only works for SAX-based sources. Is
this a
> bug in AbstractSAXSource? I think, both methods should work. I dont
> understand, why the same code works in my action and fails in the
> AbstractSAXSource?!
> 
> Do you have any idea how to solve it? I would like to use any source
for my
> action, not only sax-sources, so do i have now to check for the source
type
> and have to implement the getInputStream method for all sourcetypes
new?
> 
> Thanx
>   Tammo
> 
> PS: my new work-a-round (for sax sources only) act():
> <snip>
>                       ComponentSelector cs =
> (ComponentSelector)this.manager.lookup(Serializer.ROLE  + "Selector");
>                       Serializer serializer =
(Serializer)cs.select("xml");
> 
>             ByteArrayOutputStream os = new ByteArrayOutputStream();
>             serializer.setOutputStream(os);
>             src.toSAX(serializer);
> 
>               InputSource is = new InputSource(new
> ByteArrayInputStream(os.toByteArray()));
>                       is.setSystemId(src.getSystemId());
> 
> 
>             Parser parser = (Parser)this.manager.lookup(Parser.ROLE);
>                       Document sdoc = parser.parseDocument(is);
>                       NodeList nl =
sdoc.getElementsByTagName("document");
> </snip>


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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

Reply via email to