Re: Partial update of server side XML documents
Farrukh Najmi wrote: > Another option might be to use simpler XPath/XSLT expressions to do the > same. > > Does any one have any experience or advice on how best to do this. A proper way to do this would be an XML store and xquery or whatnot. However, most project budgets do not include that and seek such solutions for a very small subset of what the project actually does. Couple of years ago i did this two ways for a server side java app. In the first approach, the request body was always an identity_transform_based XSLT document. An identity transform is one whose transformation result tree is the same as the input tree. So, besides the identity template, that XSLT had other templates as desired. For example, suppose you only wanted to change the first heading of a document you could just use two templates: <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="//heading"> <xsl:copy> <xsl:text> added text </xsl:text> </xsl:copy> </xsl:template> In the second approach, i was sending two things with each request: an HTTP param containing an XPath expression and a request body with the XML to replace the node matched by the XPath expression. Both where sort of quick and dirty solutions but worked. In the first approach, the downside was that you had to take some care with the templates to avoid changing the wrong nodes. In the second approach you had somewhat limited capabilities as you essentially just replaced a node or fragment in the target document. I intended to add a third hybrid approach where an XPath expression would be used to extract a fragment from the target document and an XSLT would be used to transform that before putting it back but the actual need never came up. All document changes were versioned ;-) Hope this helps. Cheers, Manos
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format