Subject: Re: [xsl] XUpdate From: Mike Brown <mike@xxxxxxxx> Date: Tue, 28 Jan 2003 00:16:34 -0700 (MST) |
S Woodside wrote: > I'm considering XUpdate instead of XSLT for use to add elements to an > existing XML instance document. I'll have an XPath and the element > content as params, and the instance as input. I think XSLT would work > OK, but it seems as though XUpdate offers a lot of convenience features > I would have to write myself in XSLT to do the same thing. > > However, I noticed that XUpdate had active development and chatter on > the mailing list until early 2002 and then it died away. Is this a dead > technology? Should I roll my own in XSLT instead? We implemented XUpdate in 4Suite [1]. It works great, and if you're also using 4Suite's repository features to write a web application in XSLT, we have an XSLT extension element that invokes an XUpdate processor on that element's content, to modify documents in the repository. Sample code, based on an example in the XUpdate spec, is below. from Ft.Xml import XUpdate, InputSource xml_src = """<?xml version="1.0"?> <addresses version="1.0"> <address id="1"> <fullname>Andreas Laux</fullname> <born day='1' month='12' year='1978'/> <town>Leipzig</town> <country>Germany</country> </address> </addresses>""" xup_src = """<?xml version="1.0"?> <xupdate:modifications version="1.0" xmlns:xupdate="http://www.xmldb.org/xupdate"> <xupdate:insert-after select="/addresses/address[1]" xml:space="preserve"> <xupdate:element name="address"><xupdate:attribute name="id">2</xupdate:attribute> <fullname>Lars Martin</fullname> <born day='2' month='12' year='1974'/> <town>Leizig</town> <country>Germany</country> </xupdate:element></xupdate:insert-after> </xupdate:modifications>""" xml_isrc = InputSource.DefaultFactory.fromString(xml_src, 'http://foo/dummy.xml') xup_isrc = InputSource.DefaultFactory.fromString(xup_src, 'http://foo/dummy2.xml') processor = XUpdate.Processor() xureader = XUpdate.Reader() xml_dom = xureader.fromSrc(xml_isrc) xup_dom = xureader.fromSrc(xup_isrc) xml_dom = processor.execute(xml_dom, xup_dom) from Ft.Xml.Lib.Print import Print Print(xml_dom) Result of running the above: <?xml version="1.0" encoding="UTF-8"?> <addresses version="1.0"> <address id="1"> <fullname>Andreas Laux</fullname> <born month="12" day="1" year="1978"/> <town>Leipzig</town> <country>Germany</country> </address> <address id="2"> <fullname>Lars Martin</fullname> <born month="12" day="2" year="1974"/> <town>Leizig</town> <country>Germany</country> </address> </addresses> Mike -- Mike J. Brown | http://skew.org/~mike/resume/ Denver, CO, USA | http://skew.org/xml/ [1] http://4suite.org/ ... preferably, use latest code from CVS XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XUpdate, S Woodside | Thread | [xsl] constructing the Node Sets, Siva Jasthi |
RE: [xsl] constructing the Node Set, Roger Glover | Date | RE: [xsl] how to use namespaces wit, Pierre François |
Month |