You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Piroumian, Konstantin" <KP...@flagship.ru> on 2002/02/04 16:57:11 UTC

How to determine the end of character data?

Hi, Cocooners!

According to SAX API the parser is free to split the character data to
chunks. This causes problems in i18n transformer, which handles character
data in the 'characters(char[] ch, int start, int length)' method.

Is there a way to determine the end of the character data? The only solution
seems to be to buffer all the character data then handle it on the first
startElement() event following the characters().

Will this be correct?

Best regards,
    Konstantin Piroumian


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: How to determine the end of character data?

Posted by "Piroumian, Konstantin" <KP...@flagship.ru>.
> Sylvain Wallez wrote:
> > Martin Holz wrote:
> > >Piroumian, Konstantin wrote:
> > >>Hi, Cocooners!
> > >>
> > >>According to SAX API the parser is free to split the character data to
> > >>chunks. This causes problems in i18n transformer, which handles
character
> > >>data in the 'characters(char[] ch, int start, int length)' method.
> > >>
> > >>Is there a way to determine the end of the character data? The only
> > >>solution seems to be to buffer all the character data then handle it
on
> > >> the first startElement() event following the characters().
> > >
> > >Do you mean the next  endElement() event?
> > >
> > >>Will this be correct?
> > >
> > >Then it should be correct.
> >
> > You have to react on both start and end : startElement() starts a nested
> > child element, and endElement() terminates the current one. In both
> > cases, this means end of the current text node.
>
> Can I18NTransformer handle other elements nested into a I18N element?
>

No, only in cases when the element itself allow child elements, like
<i18n:translate>, where you can have as childs 'i18n:text' and 'i18n:param'
elements.

I've thought about nested i18n elements, CDATA elements and also i18n XML
elements when you should use XML markup inside of a localized string. e.g.:
<i18n:text>This is a <strong>bold</strong> text.</i18n:text>, but haven't
yet have time to look at it more carefully and provide some solution to
these issues.

Regards,
    Konstantin Piroumian

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: How to determine the end of character data?

Posted by Martin Holz <ho...@fiz-chemie.de>.
Sylvain Wallez wrote:
> Martin Holz wrote:
> >Piroumian, Konstantin wrote:
> >>Hi, Cocooners!
> >>
> >>According to SAX API the parser is free to split the character data to
> >>chunks. This causes problems in i18n transformer, which handles character
> >>data in the 'characters(char[] ch, int start, int length)' method.
> >>
> >>Is there a way to determine the end of the character data? The only
> >>solution seems to be to buffer all the character data then handle it on
> >> the first startElement() event following the characters().
> >
> >Do you mean the next  endElement() event?
> >
> >>Will this be correct?
> >
> >Then it should be correct.
>
> You have to react on both start and end : startElement() starts a nested
> child element, and endElement() terminates the current one. In both
> cases, this means end of the current text node.

Can I18NTransformer handle other elements nested into a I18N element?

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: How to determine the end of character data?

Posted by Sylvain Wallez <sy...@anyware-tech.com>.
Martin Holz wrote:

>Piroumian, Konstantin wrote:
>
>>Hi, Cocooners!
>>
>>According to SAX API the parser is free to split the character data to
>>chunks. This causes problems in i18n transformer, which handles character
>>data in the 'characters(char[] ch, int start, int length)' method.
>>
>>Is there a way to determine the end of the character data? The only
>>solution seems to be to buffer all the character data then handle it on the
>>first startElement() event following the characters().
>>
>
>Do you mean the next  endElement() event? 
>
>>Will this be correct?
>>
>
>Then it should be correct.
>
You have to react on both start and end : startElement() starts a nested 
child element, and endElement() terminates the current one. In both 
cases, this means end of the current text node.

Sylvain

-- 
Sylvain Wallez
Anyware Technologies - http://www.anyware-tech.com




---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: How to determine the end of character data?

Posted by "Piroumian, Konstantin" <KP...@flagship.ru>.
> Piroumian, Konstantin wrote:
> > Hi, Cocooners!
> >
> > According to SAX API the parser is free to split the character data to
> > chunks. This causes problems in i18n transformer, which handles
character
> > data in the 'characters(char[] ch, int start, int length)' method.
> >
> > Is there a way to determine the end of the character data? The only
> > solution seems to be to buffer all the character data then handle it on
the
> > first startElement() event following the characters().
>
> Do you mean the next  endElement() event?
>
> > Will this be correct?
> >
>
> Then it should be correct.

Yes, of course it must be also the endElement(). But what about this
situation:

<text>
    This is a <b>bold</b> font.
</text>

Here is the sequence of events:
startElement("text")
    characters("Test is a ")*
    startElement("b")
        characters("bold")*
    endElement("b")
    characters("font")*
endElement("text")

*)maybe chunked

As you can see either startElement() or endElement() could happen.
Any ideas how to handle this correctly?

Konstantin

>
>
> Martin
>
> --
> Martin Holz  <ho...@fiz-chemie.de>  phone: 0049-30-39977 218
> FIZ CHEMIE BERLIN
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: How to determine the end of character data?

Posted by Martin Holz <ho...@fiz-chemie.de>.
Piroumian, Konstantin wrote:
> Hi, Cocooners!
>
> According to SAX API the parser is free to split the character data to
> chunks. This causes problems in i18n transformer, which handles character
> data in the 'characters(char[] ch, int start, int length)' method.
>
> Is there a way to determine the end of the character data? The only
> solution seems to be to buffer all the character data then handle it on the
> first startElement() event following the characters().

Do you mean the next  endElement() event? 

> Will this be correct?
>

Then it should be correct.


Martin

--
Martin Holz  <ho...@fiz-chemie.de>  phone: 0049-30-39977 218 
FIZ CHEMIE BERLIN

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org