RE: Using XPath to edit an XML document

XQuery extends XPath by allowing you to define functions and to create new
elements in a result document (though not to modify the original source
document). Is that what you're looking for?

Michael Kay


> -----Original Message-----
> From: Travis Stevens [mailto:Travis.Stevens@noaa.gov] 
> Sent: 13 November 2003 00:13
> To: www-xpath-comments@w3.org
> Subject: Using XPath to edit an XML document
> 
> 
> 
> XPath has been very helpful to me querying extremely large 
> and complex 
> XML schemas (FGDC and Remote Sensing Metadata Templates FYI).  My 
> question is, why stop at querying documents.  It would be 
> very useful to 
> create xPath functions that allow one to create new Elements. 
>  For example:
> 
> Lets say we have an xml document like so:
> 
> <root>
>    <employee id="1">
>       <name first="Travex" last="Stevex" />
>       <family marriage="single" />
>    </employee>
> </root>
> 
> If I were to get married, I would create an xPath query 
> "/root/employee[@id='1']/family"
> 
> This would return the family element and I would set the marriage 
> attribute to be "married".  Well, if a family element did not exists, 
> then this query would not work.  Why not have a function to 
> create a new 
> one if it does not exist: 
> "/root/employee[@id='1']/family[createIfNonExistant()]
> 
> Lets say we want to add a new employee, xPath:
> 
> "/root/employee[new()]" would return a newly created employee element.
> 
> IMHO, I think it would only take these two functions to have 
> a sort of 
> element creational standard.
> 
> -Trav
> 

Received on Thursday, 13 November 2003 10:06:31 UTC