This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: XML -> Java Properties -> XML


Dylan,

To parse a Java properties file (and convert it into XML), why don't you
just write a SAX parser ?

You could then use such a file as an input for a SAX writer if you just
want to write it as XML, but also for any XML SAX compatible tool,
including XSLT processors.

You can find an example of a parser for another text format on 4xt:

http://4xt.org/downloads/examples/csv/

To write a Java properties file, you can do the reverse and write a SAX
writer.

This writer could filter out the namespaces and write a java property
namespace using the java syntax while keeping the HTML namespace as it
is.

Hope this helps.

Eric

Dylan Parker wrote:
> 
> Hello, all.
> 
> I am in the process of writing an XSLT sheet that converts from an XML file into
> a Java Properties file...
> 
> Why convert to the inferior properties files? Well.. until Java can read
> directly from an XML file and perform localization procedures with it... the
> properties will have to suffice. (If anybody knows of ResourceBundle classes
> that use XML.. LET ME KNOw!)
> 
> Anyways.. so I want this XML...
> ===============================
> <tag1>
>       <tag2>
>             <tag3>Here is tag3 Text</tag3>
>       </tag2>
>       <tag4>
>             Here is some tag4 text...
>             Here is another line.. CR should get converted to \n
>             Here is some embedded HTML <BR/><BR/><BR/> They should be copied
>             across.
>       </tag4>
> </tag1>
> ================================
> to be converted into this format of a property file
> ================================
> tag1.tag2.tag3=Here is tag3 Text
> tag1.tag4=Here is some tag4 text...\nHere [etc...] HTML <BR/><BR/>[etc...]
> ================================
> 
> So effectively keeping the structure of the xml.. just converted to the dotted
> notation... also Carriage returns are converted to \n's ... and HOPEFULLY the
> HTML within the XML is passed through and kept (yeah right!)...
> 
> I DO have a script that is working somewhat... but it doesn't like the HTML tags
> inside of the text... it effectively treats them like two separate text sections
> with an XML node inbetween (which it is)...
> 
> I then added a namespace to all of the XML sections to aid in filtering the non
> name-spaced HTML elements.. that's where I am now and it is getting pretty ugly.
> Anyone already done this? Can I (hopefully) stop re-inventing the wheel?
> 
> Ideally it would be nice to also convert from the Java Properties file BACK to
> the XML... but I think that is more of a PERL job than XSL... any PERL scripts
> out there to do this? (I know.. OT ..)
> 
> Any help appreciated
> 
> Thanks,
> Dylan Parker
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

-- 
------------------------------------------------------------------------
Eric van der Vlist       Dyomedea                    http://dyomedea.com
http://xmlfr.org         http://4xt.org              http://ducotede.com
------------------------------------------------------------------------


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]