Equivalence of TraxSource but based on xml file

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Equivalence of TraxSource but based on xml file

Benoit Idieder
Hi,

I am using xstream to serialize KeyStroke objects among other things, which give that kind of xml file :
 
<javax.swing.KeyStroke>
    <keyChar>&#xffff;</keyChar>
    <keyCode>116</keyCode>
    <modifiers>0</modifiers>
    <onKeyRelease>false</onKeyRelease>
</javax.swing.KeyStroke>

But now I am facing an issue as I want to run an XSL transformation on my persisted xml files ; I get this when performing the transformation :
Character reference "&#xffff" is an invalid XML character.

I realize that this char is invalid for the XML world, and that as a consequence the "standard" xml tools may fail parsing that xml file. But I found out that starting from a KeyStroke object and using TraxSource, I can perform successfully the XSL transformation.
So is there a way to get a proper Source object from the xml file ?

Regards.
Reply | Threaded
Open this post in threaded view
|

Re: Equivalence of TraxSource but based on xml file

Jörg Schaible-2
Hi Benoit,

Benoit Idieder wrote:

> Hi,
>
> I am using xstream to serialize KeyStroke objects among other things,
> which give that kind of xml file :
>
> <javax.swing.KeyStroke>
>     <keyChar>&#xffff;</keyChar>
>     <keyCode>116</keyCode>
>     <modifiers>0</modifiers>
>     <onKeyRelease>false</onKeyRelease>
> </javax.swing.KeyStroke>
>
> But now I am facing an issue as I want to run an XSL transformation on my
> persisted xml files ; I get this when performing the transformation :
> Character reference "&#xffff" is an invalid XML character.

Simply register a custom converter as local converter for KeyStroke.keyChar.
All it has to do is to write the character code as decimal. The consumer of
this XML will have to know anyway that this field might contain -1 (short
int) instead of a proper character.

> I realize that this char is invalid for the XML world, and that as a
> consequence the "standard" xml tools may fail parsing that xml file. But I
> found out that starting from a KeyStroke object and using TraxSource, I
> can perform successfully the XSL transformation.
> So is there a way to get a proper Source object from the xml file ?

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Equivalence of TraxSource but based on xml file

Benoit Idieder
Thanks for the quick answer,

The converter will be useful for future xml encoding, but I also have to deal with the xml files that already have been persisted.
Fortunately my xsl transformation was just replacing some value in xml elements, so I could do the same with a regex instead and avoid the problem.

Regards.


2013/4/27 Jörg Schaible <[hidden email]>
Hi Benoit,

Benoit Idieder wrote:

> Hi,
>
> I am using xstream to serialize KeyStroke objects among other things,
> which give that kind of xml file :
>
> <javax.swing.KeyStroke>
>     <keyChar>&#xffff;</keyChar>
>     <keyCode>116</keyCode>
>     <modifiers>0</modifiers>
>     <onKeyRelease>false</onKeyRelease>
> </javax.swing.KeyStroke>
>
> But now I am facing an issue as I want to run an XSL transformation on my
> persisted xml files ; I get this when performing the transformation :
> Character reference "&#xffff" is an invalid XML character.

Simply register a custom converter as local converter for KeyStroke.keyChar.
All it has to do is to write the character code as decimal. The consumer of
this XML will have to know anyway that this field might contain -1 (short
int) instead of a proper character.

> I realize that this char is invalid for the XML world, and that as a
> consequence the "standard" xml tools may fail parsing that xml file. But I
> found out that starting from a KeyStroke object and using TraxSource, I
> can perform successfully the XSL transformation.
> So is there a way to get a proper Source object from the xml file ?

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email