You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jarry Liu <ja...@gmail.com> on 2005/07/14 00:17:53 UTC
question about control flow and DomParser
Hi,
I am using java control flow. In the middle of the flow, I need use
DomParser function parse( String file) to read the new xml file that I
got from the pipeline. I use sourcewriting transformer to write the
new xml to disk and nameed it as temp.xml and then parse it to
DomParser. But after writing source to hard disk, I find I lost the
continuation id and can't go back to control flow. I tried to use
"redirect", but not work. Any idea to fix it ? Can I read in the new
xml file (which should be in memory) without writing to hard disk? If
so, how can I do it?
Thanks a lot.
Jarry
<!---sitemap:xmap-->
<map:match pattern="multchoice/*">
<map:generate type="jx" src="questions/{1}.xml"/>
<map:transform src="xslt/getMathML.xsl">
<map:parameter name="contextPath"
value="{request:contextPath}"/>
</map:transform>
<map:transform type="write-source">
<map:parameter name="serializer" value="xml"/>
</map:transform>
<map:transform src="xslt/redirect.xsl">
</map:transform>
<map:serialize />
</map:match>
// in java file
......
parse(temp.xml);
.....
//in getMathML.xsl:
<source:write serilizer="xml">
<source:source>page/temp.xml</source:source>
<source:fragment>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<xsl:apply-templates/>
</math>
</source:fragment>
</source:write>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: question about control flow and DomParser
Posted by Jarry Liu <ja...@gmail.com>.
Victoria,
Thanks.
I just solved this problem. Instead using Sourcewriting Transformer, I
use processPipelineTo() to transform the output to a OuptPutStream
and then I can pass this stream to DOMParser.
Here is part of the code in my java file.
ByteArrayOutputStream stream = new ByteArrayOutputStream();
String uri = "multchoice/" + problemname;
processPipelineTo(uri, dataHash, stream);
ByteArrayInputStream instream = new
ByteArrayInputStream(stream.toByteArray());
MathCal mathcal = new MathCal();
interResult = mathcal.doMathCalculate(dataHash, instream).toString();
// MathCal.java
......
public Object DoMathCalculate(Hashtable ht, ByteArrayInputStream stream) {
MathMLParser parser = new MathMLParser();
InputSource file = new InputSource(stream);
try {
parser.parse(file);
} catch(Exception e) {
e.printStackTrace();
}
.......
On 7/15/05, Victoria Vitaver <vi...@tt.com.au> wrote:
> Jarry Liu wrote:
> > Hi,
> >
> > I still have no idea how to do it. Any suggestion will be highly appreciated.
> >
> >
> >
> > On 7/13/05, Jarry Liu <ja...@gmail.com> wrote:
> >
> >>Hi,
> >>
> >>I am using java control flow. In the middle of the flow, I need use
> >>DomParser function parse( String file) to read the new xml file that I
> >>got from the pipeline. I use sourcewriting transformer to write the
> >>new xml to disk and nameed it as temp.xml and then parse it to
> >>DomParser. But after writing source to hard disk, I find I lost the
> >>continuation id and can't go back to control flow. I tried to use
> >>"redirect", but not work. Any idea to fix it ? Can I read in the new
> >>xml file (which should be in memory) without writing to hard disk? If
> >>so, how can I do it?
> >>
> >>Thanks a lot.
> >>
> >>Jarry
> >>
> >>
> >>
> >><!---sitemap:xmap-->
> >> <map:match pattern="multchoice/*">
> >> <map:generate type="jx" src="questions/{1}.xml"/>
> >> <map:transform src="xslt/getMathML.xsl">
> >> <map:parameter name="contextPath"
> >>value="{request:contextPath}"/>
> >> </map:transform>
> >> <map:transform type="write-source">
> >> <map:parameter name="serializer" value="xml"/>
> >> </map:transform>
> >> <map:transform src="xslt/redirect.xsl">
> >> </map:transform>
> >> <map:serialize />
> >> </map:match>
> >>
> >>// in java file
> >>......
> >> parse(temp.xml);
> >>.....
> >>
> >>//in getMathML.xsl:
> >>
> >><source:write serilizer="xml">
> >> <source:source>page/temp.xml</source:source>
> >> <source:fragment>
> >> <math xmlns="http://www.w3.org/1998/Math/MathML">
> >> <xsl:apply-templates/>
> >> </math>
> >> </source:fragment>
> >> </source:write>
> >>
> >
>
> I do not see the part of code where you are actually trying to use/pass through your continuation id.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: question about control flow and DomParser
Posted by Victoria Vitaver <vi...@tt.com.au>.
Jarry Liu wrote:
> Hi,
>
> I still have no idea how to do it. Any suggestion will be highly appreciated.
>
>
>
> On 7/13/05, Jarry Liu <ja...@gmail.com> wrote:
>
>>Hi,
>>
>>I am using java control flow. In the middle of the flow, I need use
>>DomParser function parse( String file) to read the new xml file that I
>>got from the pipeline. I use sourcewriting transformer to write the
>>new xml to disk and nameed it as temp.xml and then parse it to
>>DomParser. But after writing source to hard disk, I find I lost the
>>continuation id and can't go back to control flow. I tried to use
>>"redirect", but not work. Any idea to fix it ? Can I read in the new
>>xml file (which should be in memory) without writing to hard disk? If
>>so, how can I do it?
>>
>>Thanks a lot.
>>
>>Jarry
>>
>>
>>
>><!---sitemap:xmap-->
>> <map:match pattern="multchoice/*">
>> <map:generate type="jx" src="questions/{1}.xml"/>
>> <map:transform src="xslt/getMathML.xsl">
>> <map:parameter name="contextPath"
>>value="{request:contextPath}"/>
>> </map:transform>
>> <map:transform type="write-source">
>> <map:parameter name="serializer" value="xml"/>
>> </map:transform>
>> <map:transform src="xslt/redirect.xsl">
>> </map:transform>
>> <map:serialize />
>> </map:match>
>>
>>// in java file
>>......
>> parse(temp.xml);
>>.....
>>
>>//in getMathML.xsl:
>>
>><source:write serilizer="xml">
>> <source:source>page/temp.xml</source:source>
>> <source:fragment>
>> <math xmlns="http://www.w3.org/1998/Math/MathML">
>> <xsl:apply-templates/>
>> </math>
>> </source:fragment>
>> </source:write>
>>
>
I do not see the part of code where you are actually trying to use/pass through your continuation id.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: question about control flow and DomParser
Posted by Jarry Liu <ja...@gmail.com>.
Hi,
I still have no idea how to do it. Any suggestion will be highly appreciated.
On 7/13/05, Jarry Liu <ja...@gmail.com> wrote:
> Hi,
>
> I am using java control flow. In the middle of the flow, I need use
> DomParser function parse( String file) to read the new xml file that I
> got from the pipeline. I use sourcewriting transformer to write the
> new xml to disk and nameed it as temp.xml and then parse it to
> DomParser. But after writing source to hard disk, I find I lost the
> continuation id and can't go back to control flow. I tried to use
> "redirect", but not work. Any idea to fix it ? Can I read in the new
> xml file (which should be in memory) without writing to hard disk? If
> so, how can I do it?
>
> Thanks a lot.
>
> Jarry
>
>
>
> <!---sitemap:xmap-->
> <map:match pattern="multchoice/*">
> <map:generate type="jx" src="questions/{1}.xml"/>
> <map:transform src="xslt/getMathML.xsl">
> <map:parameter name="contextPath"
> value="{request:contextPath}"/>
> </map:transform>
> <map:transform type="write-source">
> <map:parameter name="serializer" value="xml"/>
> </map:transform>
> <map:transform src="xslt/redirect.xsl">
> </map:transform>
> <map:serialize />
> </map:match>
>
> // in java file
> ......
> parse(temp.xml);
> .....
>
> //in getMathML.xsl:
>
> <source:write serilizer="xml">
> <source:source>page/temp.xml</source:source>
> <source:fragment>
> <math xmlns="http://www.w3.org/1998/Math/MathML">
> <xsl:apply-templates/>
> </math>
> </source:fragment>
> </source:write>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org