You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Tammo van Lessen <cu...@taval.de> on 2002/07/23 13:12:27 UTC

AW: parse generated xml and react in sitemap (Problem with AbstractSAXSource)

| Von: Vadim Gritsenko [mailto:vadim.gritsenko@verizon.net]
|
|
| 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(Abstrac
tSAXSource.java:133)
	at
org.apache.cocoon.components.source.AbstractSAXSource.getInputSource(Abstrac
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:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


AW: parse generated xml and react in sitemap (Problem with AbstractSAXSource)

Posted by Tammo van Lessen <cu...@taval.de>.
Vadim,
I use Cocoon 2.0.3!

I will try to access some cocoon:// sources, but the SiteMapSource source
(especially getInputStream()) has changed since file revision 1.3, so I
think, this testcase wont help us.

I've tries to debug the AbstractSAXSource and I have find out, that
	serializerSelector = (ComponentSelector)
this.manager.lookup(Serializer.ROLE + "Selector");
returns an empty ComponentSelector object, and thats why the following line
fails selecting the "xml"-serializer.

I hope, this could help you...

Thanx,
  Tammo

| -----Ursprungliche Nachricht-----
| Von: Vadim Gritsenko [mailto:vadim.gritsenko@verizon.net]
| Gesendet: Mittwoch, 24. Juli 2002 04:17
| An: cocoon-users@xml.apache.org
| Betreff: RE: parse generated xml and react in sitemap (Problem with
| AbstractSAXSource)
|
|
| 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:cusers-list@taval.de]
| > Sent: Tuesday, July 23, 2002 7:12 AM
| > To: cocoon-users@xml.apache.org
| > Subject: AW: parse generated xml and react in sitemap (Problem with
| > AbstractSAXSource)
| >
| > | Von: Vadim Gritsenko [mailto:vadim.gritsenko@verizon.net]
| > |
| > |
| > | 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:     <co...@xml.apache.org>
| For additional commands, e-mail:   <co...@xml.apache.org>
|


---------------------------------------------------------------------
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:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


RE: parse generated xml and react in sitemap (Problem with AbstractSAXSource)

Posted by Vadim Gritsenko <va...@verizon.net>.
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:cusers-list@taval.de]
> Sent: Tuesday, July 23, 2002 7:12 AM
> To: cocoon-users@xml.apache.org
> Subject: AW: parse generated xml and react in sitemap (Problem with
> AbstractSAXSource)
> 
> | Von: Vadim Gritsenko [mailto:vadim.gritsenko@verizon.net]
> |
> |
> | 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:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>