OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] 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:apply-templates select="@*|node()"/>

<xsl:template match="//heading[1]">
    <xsl:text> added text </xsl:text>

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.



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS