Re: generating attributes and content for an element
"Tod Harter" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
XSLT is designed primarily to transform XML to XML. It CAN output text or html, but its forte is really XML to XML transformations, so in that sense it is pretty much exactly what you want. The caveats are that if you have VERY large documents the memory requirements can be high, and if your input is not XML then you may have to jump through a few hoops to get it into a libxml document object (but there are good ways to do this) and the final caveat being it can be a bit annoying to output text with XSLT, but I have gotten perfectly acceptible results, it is just a bit picky about how the stylesheet is formatted (white space handling in XSLT is a bit obtuse). On Mon, Nov 24, 2008 at 9:31 AM, Manuel Souto Pico < [email protected]> wrote: > Thank you, Michael, Tod and Shlomi, > > I don't know a lot about XSL(T) but from the little I know it seems that it > is used when you need to give a human-friendly shape to an XML document > (e.g. roughly, show the XML contents as if it was a webpage in a navigator). > > > However, the conversion that I need to do is from XML to another XML-based > format (that ISO standard I mentioned earlier, called Martif/TBX). The TBX > file would then be importable for the tools I use. You can see what > Martif/TBX looks like here (pages 7-12): > http://www.tiu.ac.jp/org/openforum2006/slides/P5.pdf > > So do you still think XSLT would be the right thing for me? > > Thanks! > Regards, Manuel > > Tod Harter escribió: > > Yeah, that was going to be my suggestion, if you use XML::LibXML then take > a look at XML::LibXSLT as well. It has been a LONG while since I installed > those on Windows though (and my company is actually sans MS!!!) so off the > top of my head all I can tell you is that it is certainly possible to > install those modules on Windows. The only part I'm not 100% sure about > actually is getting libxml installed, once you do that either PPM with > activestate perl or CPAN with regular old perl windows build will do the > perl part with no problem. > > http://www.zlatkovic.com/pub/libxml/ appears to have binaries of the DLLs > for libxml and libxslt2, check it out ;) Bit more work to get started but > you get bog standard XML processing capabilities out of it. > > And personlly I second the 'use XSLT' idea. Again it is a bit more learning > curve to start, but if you do this kind of thing at all often, XSLT is a lot > easier way to go than fudging around in any standard language, plus you can > always run the transform on ANY compliant engine. > > On Mon, Nov 24, 2008 at 8:20 AM, Michael Ludwig <[email protected]> wrote: > >> Manuel Souto Pico schrieb: >> > Michael Ludwig escribió: >> >> Manuel Souto Pico schrieb: >> >>> >> >>> my $data = { >> >>> e => ['element value'], >> >>> a => 'attribute value'* >> >>> *}; >> >> >> >> This is a syntax error, and incomplete. You're using XML::Simple, >> >> which may become very complicated if what you want to do isn't simple >> >> enough. >> >> >> > I'm sorry, what is the syntax error exactly? If you are referring to >> > the absent comma, I though it wasn't needed after the last element >> > before the block-closing bracket. >> >> It isn't, you're correct. I was referring to the asterisks ** :-) >> >> > Could you believe that I had already tried this? :) Using the word >> > 'content' was my first guess, but it didn't work. I probably had the >> > brackets wrong or something. But it does work now! >> >> I believe you, no question - I started out myself getting the brackets >> wrong. Well, that's XML::Simple for you. As Shlomi has pointed out, it's >> a kludgy way of dealing with XML. >> >> > By the way, in case you are interested, what I'm doing is converting a >> > dictionary that I have in XML to Martif format. With XMLin I captured >> > the original dictionary and now I'm trying to transfer the contents to >> > the new structure. >> >> I don't know Martif, but it sounds like you should be using a high-level >> language instead. Consider using XSLT - it'll pay off. >> >> Michael Ludwig >> _______________________________________________ >> Perl-XML mailing list >> [email protected] >> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs >> > > > > -- > The Wise adapts himself to the world. The Fool adapts the world to himself. > Therefore, all progress depends on the Fool. > > ------------------------------ > > _______________________________________________ > Perl-XML mailing [email protected] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > -- The Wise adapts himself to the world. The Fool adapts the world to himself. Therefore, all progress depends on the Fool. _______________________________________________ Perl-XML mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs