Hello again!
I have a problem con the Encode of the xml. I'm doing a submission of a instace. Then a Servlet get the xml, with request.getInputStream(), as a String. But this xml is something like that: <?xml version="1.0" encoding="UTF-8"?><documento><CodMap>á</CodMap>... The default encode is UTF-8, so the element CodMap contains "á", but the correct caracter is "á": It is possible to change de encoding for iso-8859-1?? Or what is the correct way to solve this problem? Thank you very much in advance. Busca desde cualquier página Web con una protección excepcional. Consigue la Barra de herramientas de Windows Live hoy mismo GRATUITAMENTE. Pruébalo -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Hi,
Could you help me to solve how to alternate row styles? Even if this is a very common task and should be easy to implement, at least I hope so, I am unable I found any examples or make my code work. I fould an old post (see below) related to the problem but it did not provide any (complete) solution. If someone could take a look at my code (attached) and tell me how to fix it i.e. sort names so that odd and even rows have different row styles. Thanks in advance! -Markku Laine --------------------- 8< ------------------- David, Unfortunately I don't know of a better way. Once we support Attribute Value Templates (AVTs) in XHTML then we should have a better way, and you could write: <xhtml:tr class="{if (position() % 2 = 0) then 'foo' else 'bar'}"> But for now this won't work as XForms does not support AVTs and we do not implement them as an extension in the XHTML yet. -Erik > David Sinclair wrote: > Hi, > > Does anyone have any suggestions on the best way to have alternating row > styles in a table using xforms:repeat? > > The only way we can see it to have 2 groups withins the repeat, each > matching either odd or even position() values. I dont like this idea as > it > involves repeating a chunk of code just to have a different class on the > <tr>. Is there a better way? > > > Thanks in advance, > > Dave -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws alternating_row_styles.xhtml (3K) Download Attachment |
Administrator
|
In reply to this post by aa aa-2
On 7/6/07, aa aa <[hidden email]> wrote:
> But this xml is something like that: > > <?xml version="1.0" > encoding="UTF-8"?><documento><CodMap>á</CodMap>... > > The default encode is UTF-8, so the element CodMap contains "á", but the > correct caracter is "á": > > It is possible to change de encoding for iso-8859-1?? Or what is the > correct way to solve this problem? you have this problem because you don't specify an encoding, and the default encoding is picked (iso-8859-1), which in this case is not the right one. Instead, it is better to use an XML parser to read the input stream. You can do this by using the static Dom4jUtils.readDom4j(inputStream) which returns a Dom4j document (this is in the org.orbeon.oxf.xml.dom4j package). I hope this helps, Alex -- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
In reply to this post by aa aa-2
Hello.
Now I'm reading the input stream like that: InputStreamReader inputStream = new InputStreamReader(request.getInputStream());Document documento = Dom4jUtils.readDom4j(inputStream); documento.setXMLEncoding( "utf-8"); return documento.asXML();But I have the same problem, the caracters with acent. And the console says that: ------------ log -------------------------------------------------- 2007-07-09 12:20:55,768 http-8080-Processor48 DEBUG processor.XFormsServer null - XForms - setting request body: <?xml version="1.0" encoding="UTF-8"?><files xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms"><file filename="InfoAdicional01.xml" mediatype="text/xml" size="5142">file:/C:/Documents%20and%20Settings/rlopezro/Configuración%20local/Temp/xforms_upload_34209.tmp</file></files> -------------- System.out.pritln of the xml in my servlet -------------- <?xml version="1.0" encoding="utf-8"?> <files xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms"><file filename="InfoAdicional01.xml" mediatype="text/xml" size="5142">file:/C:/Documents%20and%20Settings/rlopezro/Configuración%20local/Temp/xforms_upload_34209.tmp</file></files> ----------------------------------------At the first line (log) is all correct. But when I println the document in my servlet (with utf-8 or iso-8859-1 encoding) the caracter "ó" is wrong. Can somebody help me? > Date: Sun, 8 Jul 2007 00:30:47 -0700 > From: [hidden email] > To: [hidden email] > Subject: Re: [ops-users] Encode in xml with accent > > On 7/6/07, aa aa <[hidden email]> wrote: > > But this xml is something like that: > > > > <?xml version="1.0" > > encoding="UTF-8"?><documento><CodMap>á</CodMap>... > > > > The default encode is UTF-8, so the element CodMap contains "á", but the > > correct caracter is "á": > > > > It is possible to change de encoding for iso-8859-1?? Or what is the > > correct way to solve this problem? > > How are you converting the input stream to a string? My guess it that > you have this problem because you don't specify an encoding, and the > default encoding is picked (iso-8859-1), which in this case is not the > right one. Instead, it is better to use an XML parser to read the > input stream. You can do this by using the static > Dom4jUtils.readDom4j(inputStream) which returns a Dom4j document (this > is in the org.orbeon.oxf.xml.dom4j package). > > I hope this helps, > > Alex > -- > Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise > http://www.orbeon.com/ > Llama a tus amigos de PC a PC: ¡Es GRATIS! Pruébalo -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
> Now I'm reading the input stream like that:
> > InputStreamReader inputStream = *new* > InputStreamReader(request.getInputStream()); > > Document documento = Dom4jUtils./readDom4j/(inputStream); > > documento.setXMLEncoding("utf-8"); One word: ouch. That won't work in the general case. The part of the code above which needs to know the encoding of the source is the InputStreamReader. Here, if you don't pass it an encoding (which should be prevented by the Java API in my opinion), the platform's default charset, which is rarely the right one. There is more: in XML, you should *not* specify the encoding externally, since XML is a self-describing format which specifies the correct encoding on its own using the XML declaration (if there is no XML declaration, then the encoding is UTF-8). From that perspective, XML is not strictly a text format, which is why you should always use application/xml and not text/xml as a content type / media type. The bottom line: in Java, you should always pass an InputStream to an XML parser, and never pass a Reader. So the first thing to do is change your code to: Dom4jUtils.readDom4j(request.getInputStream()); -Erik -- Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
In reply to this post by Markku Laine
Markku,
We still do not support AVTs on (X)HTML markup, but that is coming real soon. In the meanwhile, you could use groups around rows, which has the drawback of requiring repeating the content. See example attached, now also part of the sandbox samples. -Erik .::: Markku :::. wrote: > Hi, > > > Could you help me to solve how to alternate row styles? Even if this is > a very common task and should be easy to implement, at least I hope so, > I am unable I found any examples or make my code work. I fould an old > post (see below) related to the problem but it did not provide any > (complete) solution. > > If someone could take a look at my code (attached) and tell me how to > fix it i.e. sort names so that odd and even rows have different row styles. > > Thanks in advance! > > > -Markku Laine > > > > --------------------- 8< ------------------- > David, > > Unfortunately I don't know of a better way. Once we support Attribute > Value Templates (AVTs) in XHTML then we should have a better way, and > you could write: > > > <xhtml:tr class="{if (position() % 2 = 0) then 'foo' else 'bar'}"> > > But for now this won't work as XForms does not support AVTs and we do > not implement them as an extension in the XHTML yet. > > > -Erik > >> David Sinclair wrote: >> Hi, >> >> Does anyone have any suggestions on the best way to have alternating >> row styles in a table using xforms:repeat? >> >> The only way we can see it to have 2 groups withins the repeat, each >> matching either odd or even position() values. I dont like this idea >> as it involves repeating a chunk of code just to have a different >> class on the <tr>. Is there a better way? >> >> >> Thanks in advance, >> >> Dave -- Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws alternating-rows.xhtml (4K) Download Attachment |
Hi Erik,
Thanks for your example and updated information about the AVTs. I am looking forward to the feature! However, the example that you sent does not completely solve the problem I have or what I tried to demonstrate in my previous example. Your example shows how to set alternating row styles and it works fine _IF_ the data has been sorted in advance. _BUT_ what if the data has not been sorted in advance? In the attached example (modified your example a bit), I have changed the order of the items and used the exforms:sort function in the xforms:repeat element to sort the items. Now, as you can see, the row styles are not correct anymore. Could you demonstrate how to sort the items _AND_ set alternating row styles to the items correctly or is it even possible when using exforms:sort()? Best regards -Markku Laine On Mon, 9 Jul 2007, Erik Bruchez wrote: > Markku, > > We still do not support AVTs on (X)HTML markup, but that is coming real soon. > > In the meanwhile, you could use groups around rows, which has the drawback of > requiring repeating the content. See example attached, now also part of the > sandbox samples. > > -Erik > > .::: Markku :::. wrote: >> Hi, >> >> >> Could you help me to solve how to alternate row styles? Even if this is a >> very common task and should be easy to implement, at least I hope so, I am >> unable I found any examples or make my code work. I fould an old post (see >> below) related to the problem but it did not provide any (complete) >> solution. >> >> If someone could take a look at my code (attached) and tell me how to fix >> it i.e. sort names so that odd and even rows have different row styles. >> >> Thanks in advance! >> >> >> -Markku Laine >> >> >> >> --------------------- 8< ------------------- >> David, >> >> Unfortunately I don't know of a better way. Once we support Attribute >> Value Templates (AVTs) in XHTML then we should have a better way, and you >> could write: >> >> >> <xhtml:tr class="{if (position() % 2 = 0) then 'foo' else 'bar'}"> >> >> But for now this won't work as XForms does not support AVTs and we do not >> implement them as an extension in the XHTML yet. >> >> >> -Erik >> >> > David Sinclair wrote: >> > Hi, >> > >> > Does anyone have any suggestions on the best way to have alternating row >> > styles in a table using xforms:repeat? >> > >> > The only way we can see it to have 2 groups withins the repeat, each >> > matching either odd or even position() values. I dont like this idea as >> > it involves repeating a chunk of code just to have a different class on >> > the <tr>. Is there a better way? >> > >> > >> > Thanks in advance, >> > >> > Dave > > > -- > Orbeon Forms - Web Forms for the Enterprise Done the Right Way > http://www.orbeon.com/ > -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws alternating-rows-2.xhtml (4K) Download Attachment |
Administrator
|
Markku,
On 7/9/07, .::: Markku :::. <[hidden email]> wrote: > Could you demonstrate how to sort the items _AND_ set alternating row > styles to the items correctly or is it even possible when using > exforms:sort()? I see: in this case, the ref expressions should be of the form: ref="if (position() != 1) then . else ()", i.e. use position() instead of relying on the position of the nodes. But while position() works in say an <xforms:output value="..."> unfortunately it doesn't seem to work in this case. I have added a bug for this: http://forge.objectweb.org/tracker/index.php?func=detail&aid=307268&group_id=168&atid=350207 Alex -- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
> I see: in this case, the ref expressions should be of the form:
> ref="if (position() != 1) then . else ()", i.e. use position() instead > of relying on the position of the nodes. But while position() works in > say an <xforms:output value="..."> unfortunately it doesn't seem to > work in this case. I have added a bug for this: > > http://forge.objectweb.org/tracker/index.php?func=detail&aid=307268&group_id=168&atid=350207 Alex ja Erik, thanks for showing the example and pointing out the bug. BR -Markku -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
In reply to this post by aa aa-2
Thank you very much!
That's just the problem. When I did the NEW I lost the default encode. Thanks! > Date: Mon, 9 Jul 2007 15:24:22 +0200 > From: [hidden email] > To: [hidden email] > Subject: Re: [ops-users] Encode in xml with accent > > > Now I'm reading the input stream like that: > > > > InputStreamReader inputStream = *new* > > InputStreamReader(request.getInputStream()); > > > > Document documento = Dom4jUtils./readDom4j/(inputStream); > > > > documento.setXMLEncoding("utf-8"); > > One word: ouch. > > That won't work in the general case. The part of the code above which > needs to know the encoding of the source is the > InputStreamReader. > > Here, if you don't pass it an encoding (which should be prevented by > the Java API in my opinion), the platform's default charset, which is > rarely the right one. > > There is more: in XML, you should *not* specify the encoding > externally, since XML is a self-describing format which specifies the > correct encoding on its own using the XML declaration (if there is no > XML declaration, then the encoding is UTF-8). From that perspective, > XML is not strictly a text format, which is why you should always use > application/xml and not text/xml as a content type / media type. > > The bottom line: in Java, you should always pass an InputStream to an > XML parser, and never pass a Reader. > > So the first thing to do is change your code to: > > Dom4jUtils.readDom4j(request.getInputStream()); > > -Erik > > -- > Orbeon Forms - Web Forms for the Enterprise Done the Right Way > http://www.orbeon.com/ > > Consigue el nuevo Windows Live Messenger Pruébalo -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
Glad it's working!
-Erik aa aa wrote: > Thank you very much! > > That's just the problem. When I did the NEW I lost the default encode. > > Thanks! > > > Date: Mon, 9 Jul 2007 15:24:22 +0200 > > From: [hidden email] > > To: [hidden email] > > Subject: Re: [ops-users] Encode in xml with accent > > > > > Now I'm reading the input stream like that: > > > > > > InputStreamReader inputStream = *new* > > > InputStreamReader(request.getInputStream()); > > > > > > Document documento = Dom4jUtils./readDom4j/(inputStream); > > > > > > documento.setXMLEncoding("utf-8"); > > > > One word: ouch. > > > > That won't work in the general case. The part of the code above which > > needs to know the encoding of the source is the > > InputStreamReader. > > > > Here, if you don't pass it an encoding (which should be prevented by > > the Java API in my opinion), the platform's default charset, which is > > rarely the right one. > > > > There is more: in XML, you should *not* specify the encoding > > externally, since XML is a self-describing format which specifies the > > correct encoding on its own using the XML declaration (if there is no > > XML declaration, then the encoding is UTF-8). From that perspective, > > XML is not strictly a text format, which is why you should always use > > application/xml and not text/xml as a content type / media type. > > > > The bottom line: in Java, you should always pass an InputStream to an > > XML parser, and never pass a Reader. > > > > So the first thing to do is change your code to: > > > > Dom4jUtils.readDom4j(request.getInputStream()); > > > > -Erik > > > > -- > > Orbeon Forms - Web Forms for the Enterprise Done the Right Way > > http://www.orbeon.com/ > > > > > > > ------------------------------------------------------------------------ > Consigue el nuevo Windows Live Messenger Pruébalo > <http://get.live.com/messenger/overview> > -- Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
In reply to this post by Markku Laine
.::: Markku :::. wrote:
>> I see: in this case, the ref expressions should be of the form: >> ref="if (position() != 1) then . else ()", i.e. use position() instead >> of relying on the position of the nodes. But while position() works in >> say an <xforms:output value="..."> unfortunately it doesn't seem to >> work in this case. I have added a bug for this: >> >> http://forge.objectweb.org/tracker/index.php?func=detail&aid=307268&group_id=168&atid=350207 >> > > Alex ja Erik, thanks for showing the example and pointing out the bug. -Erik -- Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
In reply to this post by Markku Laine
Markku,
On 7/9/07, .::: Markku :::. <[hidden email]> wrote: > Alex ja Erik, thanks for showing the example and pointing out the bug. As Erik mentioned, he fixed the issue with position(). So if you get a new nightly build, you can give a try to the method shown in the attached file. Alex -- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws alternating-rows-2.xhtml (5K) Download Attachment |
> As Erik mentioned, he fixed the issue with position(). So if you get a
> new nightly build, you can give a try to the method shown in the > attached file. Wow, that was fast! Thanks guys! -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
In reply to this post by Alessandro Vernet
> As Erik mentioned, he fixed the issue with position(). So if you get a
> new nightly build, you can give a try to the method shown in the > attached file. I tested the bug fix with the newest nightly build available from your website. The position() function works fine in ref, when used like e.g.: <xforms:group ref="if( ( position() mod 2 ) = 0 ) then . else()"> But it does not work when used like e.g.: <xforms:group ref=".[ ( ( position() mod 2 ) = 0 ) ]"> OR <xforms:group ref=".[ position() = 2 ]"> In the latter two cases or the position() function always returns 1. Please, see the test cases in the attachment. Regards -Markku Laine -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws alternating-rows-3.xhtml (8K) Download Attachment |
Administrator
|
.::: Markku :::. wrote:
>> As Erik mentioned, he fixed the issue with position(). So if you get a >> new nightly build, you can give a try to the method shown in the >> attached file. > > I tested the bug fix with the newest nightly build available from your > website. The position() function works fine in ref, when used like e.g.: > <xforms:group ref="if( ( position() mod 2 ) = 0 ) then . else()"> > > But it does not work when used like e.g.: > <xforms:group ref=".[ ( ( position() mod 2 ) = 0 ) ]"> > OR > <xforms:group ref=".[ position() = 2 ]"> > > In the latter two cases or the position() function always returns 1. predicate (something between square brackets), the evaluation context changes. Here, the context changes to the current node ("."), which has a size of 1, and the position within that context is 1. What you could do is something like this: <xforms:group ref="for $position in position() return .[(($position mod 2) = 0)]"> -Erik -- Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Free forum by Nabble | Edit this page |