From: <mgr...@co...> - 2003-08-28 19:05:22
|
Here is what was my original thinking on using XPATH expressions in r-values for edit. Right now to update attribute value you would do something like xml ed -u //@id -v 2 //@id - points to a node being updated 2 - specifies value (constant) Here is how I would envision incremental update xml ed -u //@id -x "@id+1" //@id - points to a node/nodes being updated and gives a context for xpath expressions @id+1 - specifies xpath expression within the context defined in -u option. This expression evaluates and its value is assigned to a node selected in -u. Something like that... --Mikhail > I did not put much thought yet but here is an idea... > > With the xml ed, we are actually replacing something with something else. So > the basic idea is xml ed -u "..." -x "..." where -u is the r-left and -x is > the r-right values. > > However, it is often difficult to construct an XPath for the r-value in one > statement. I was rather thinking something in the line of : > > xml ed -u "..." -r ...multiple statements... > > In multiple statements we must be able to match (-m), copy (-c), add a tag > (-e), get a value (-v), evaluate an XPath (-x), delete a tag (-d) and maybe > more. Each of these actions are "piped" together as usual, and the result of > the last command will be pasted in the l-value. I dont know what can happen > if you try to replace an attribute with an XML node instead of a value? > > Therefore we could do something like: > > xml ed -u "..." -r -m "/Record/Number" -v "node()" -x "some XPath that adds > 1 to the -v" ... > > This example is obvisouly overkill for what it does. > > Daniel Shane > > |
From: <mgr...@co...> - 2003-08-28 19:45:55
|
Honestly I do not see much differences between element and attribute in that sense. (They are both nodes after all). Scenario you described can be achieved by combining multiple --insert, --append, --subnode which would look more natural and easier to read (I believe :)) --Mikhail > That works ok for attributes, but what if you want to update an XML node? In > that case would it be favorable to have multiple right hand side actions > before doing the affectation? In many cases the replacement is a > construction of elements rather than simply another part of the tree. > > Daniel Shane > > -----Original Message----- > From: xml...@li... > [mailto:xml...@li...]On Behalf Of > mgr...@co... > Sent: Thursday, August 28, 2003 2:54 PM > To: xml...@li... > Cc: Daniel Shane > Subject: RE: [Xmlstar-devel] Great! > > > Here is what was my original thinking on using XPATH expressions in r-values > for edit. > > Right now to update attribute value you would do something like > > xml ed -u //@id -v 2 > > //@id - points to a node being updated > 2 - specifies value (constant) > > > Here is how I would envision incremental update > > xml ed -u //@id -x "@id+1" > > //@id - points to a node/nodes being updated > and gives a context for xpath expressions > > @id+1 - specifies xpath expression within the context > defined in -u option. This expression evaluates > and its value is assigned to a node selected > in -u. > > Something like that... > > --Mikhail > > |
From: Daniel S. <sh...@ir...> - 2003-08-29 14:00:42
|
Hehe! I'm still too new to this tool to fully understand all the combinations. However, is it normal that the --insert inserts not "inside" the XPath but "outside" of it? Ex. xml ed -i "/xml" -t elem -n "test" -v 5 this will add test before xml and not inside it. Then what should xml ed -i "/" -t elem -n "test" -v 5 do? Daniel Shane -----Original Message----- From: mgr...@co... [mailto:mgr...@co...] Sent: Thursday, August 28, 2003 3:37 PM To: xml...@li... Cc: Daniel Shane Subject: RE: [Xmlstar-devel] Great! Honestly I do not see much differences between element and attribute in that sense. (They are both nodes after all). Scenario you described can be achieved by combining multiple --insert, --append, --subnode which would look more natural and easier to read (I believe :)) --Mikhail > That works ok for attributes, but what if you want to update an XML node? In > that case would it be favorable to have multiple right hand side actions > before doing the affectation? In many cases the replacement is a > construction of elements rather than simply another part of the tree. > > Daniel Shane > > -----Original Message----- > From: xml...@li... > [mailto:xml...@li...]On Behalf Of > mgr...@co... > Sent: Thursday, August 28, 2003 2:54 PM > To: xml...@li... > Cc: Daniel Shane > Subject: RE: [Xmlstar-devel] Great! > > > Here is what was my original thinking on using XPATH expressions in r-values > for edit. > > Right now to update attribute value you would do something like > > xml ed -u //@id -v 2 > > //@id - points to a node being updated > 2 - specifies value (constant) > > > Here is how I would envision incremental update > > xml ed -u //@id -x "@id+1" > > //@id - points to a node/nodes being updated > and gives a context for xpath expressions > > @id+1 - specifies xpath expression within the context > defined in -u option. This expression evaluates > and its value is assigned to a node selected > in -u. > > Something like that... > > --Mikhail > > |
From: Mikhail G. <mgr...@co...> - 2003-08-29 15:10:15
|
insert - adds a node before selected node on same level append - adds a node after selected node on same level subnode - creates a child xml ed -i "/" -t elem -n "test" -v 5 does nothing. Actually command line options for 'edit' are not finalized. Some things are clearly missing. Ex. ability do add attributes together with element, ablility to modify nodes based on their current values. I pretty much realize what is missing, the main question is how to implement these missing functions so that it will be easir to use and it is still readable. I was also thinking about implementing 'edit' in similar approach to 'select' i.e. generate xpdate document based on command line options and implement xupdate see http://www.xmldb.org/xupdate/xupdate-wd.html ----- Original Message ----- From: "Daniel Shane" <sh...@ir...> To: <mgr...@co...>; <xml...@li...> Sent: Friday, August 29, 2003 10:05 AM Subject: RE: [Xmlstar-devel] Great! > Hehe! > > I'm still too new to this tool to fully understand all the combinations. > However, is it normal that the --insert inserts not "inside" the XPath but > "outside" of it? > > Ex. xml ed -i "/xml" -t elem -n "test" -v 5 > > this will add test before xml and not inside it. Then what should > > xml ed -i "/" -t elem -n "test" -v 5 > > do? > > Daniel Shane > > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.514 / Virus Database: 312 - Release Date: 8/28/2003 |
From: Daniel S. <sh...@ir...> - 2003-08-29 16:55:22
|
I understand the need for the current semantic of --insert, but if I want to insert a node inside another node at the begining I need to do something like: xml ed -i "/node1/*[1]" -t elem -n "test" -v ... What if there is no node in node1? On the otherhand, subnode always adds at the end. I think we are missing something. I understand the need to refine the edit command, and I will try to think about how it should be implemented. Maybe I can give you some ideas. I agree that the edit feature should look alot like the sel feature. I think that edit could be a sel which is then inserted, appended etc... Why not have something like: xml ed .... sel .... We would evaluate the sel with exactly the select module and then paste/insert whatever the sel returned in the target XPath? I mean, for example incrementing an ID by one could also be implemented in the select module. There is no need for it to be only in the edit module? Daniel Shane -----Original Message----- From: xml...@li... [mailto:xml...@li...]On Behalf Of Mikhail Grushinskiy Sent: Friday, August 29, 2003 11:05 AM To: Daniel Shane; xml...@li... Subject: Re: [Xmlstar-devel] Great! insert - adds a node before selected node on same level append - adds a node after selected node on same level subnode - creates a child xml ed -i "/" -t elem -n "test" -v 5 does nothing. Actually command line options for 'edit' are not finalized. Some things are clearly missing. Ex. ability do add attributes together with element, ablility to modify nodes based on their current values. I pretty much realize what is missing, the main question is how to implement these missing functions so that it will be easir to use and it is still readable. I was also thinking about implementing 'edit' in similar approach to 'select' i.e. generate xpdate document based on command line options and implement xupdate see http://www.xmldb.org/xupdate/xupdate-wd.html ----- Original Message ----- From: "Daniel Shane" <sh...@ir...> To: <mgr...@co...>; <xml...@li...> Sent: Friday, August 29, 2003 10:05 AM Subject: RE: [Xmlstar-devel] Great! > Hehe! > > I'm still too new to this tool to fully understand all the combinations. > However, is it normal that the --insert inserts not "inside" the XPath but > "outside" of it? > > Ex. xml ed -i "/xml" -t elem -n "test" -v 5 > > this will add test before xml and not inside it. Then what should > > xml ed -i "/" -t elem -n "test" -v 5 > > do? > > Daniel Shane > > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.514 / Virus Database: 312 - Release Date: 8/28/2003 ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ xmlstar-devel mailing list xml...@li... https://lists.sourceforge.net/lists/listinfo/xmlstar-devel |
From: Daniel S. <sh...@ir...> - 2003-08-29 14:03:50
|
Is it possible with -i to add a node with an attribute at the same time? Ex: xml ed -i "/xml" -t elem -n "test" -v 5 -t attr -n "id" -v 5 Does not seem to work... Daniel Shane |
From: Mikhail G. <mgr...@co...> - 2003-08-29 14:44:55
|
No it is not possible right now ----- Original Message ----- From: "Daniel Shane" <sh...@ir...> To: <mgr...@co...>; <xml...@li...> Sent: Friday, August 29, 2003 10:08 AM Subject: Adding a node... > Is it possible with -i to add a node with an attribute at the same time? > > Ex: xml ed -i "/xml" -t elem -n "test" -v 5 -t attr -n "id" -v 5 > > Does not seem to work... > > Daniel Shane --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.514 / Virus Database: 312 - Release Date: 8/28/2003 |
From: Daniel S. <sh...@ir...> - 2003-08-28 19:26:43
|
That works ok for attributes, but what if you want to update an XML node? In that case would it be favorable to have multiple right hand side actions before doing the affectation? In many cases the replacement is a construction of elements rather than simply another part of the tree. Daniel Shane -----Original Message----- From: xml...@li... [mailto:xml...@li...]On Behalf Of mgr...@co... Sent: Thursday, August 28, 2003 2:54 PM To: xml...@li... Cc: Daniel Shane Subject: RE: [Xmlstar-devel] Great! Here is what was my original thinking on using XPATH expressions in r-values for edit. Right now to update attribute value you would do something like xml ed -u //@id -v 2 //@id - points to a node being updated 2 - specifies value (constant) Here is how I would envision incremental update xml ed -u //@id -x "@id+1" //@id - points to a node/nodes being updated and gives a context for xpath expressions @id+1 - specifies xpath expression within the context defined in -u option. This expression evaluates and its value is assigned to a node selected in -u. Something like that... --Mikhail > I did not put much thought yet but here is an idea... > > With the xml ed, we are actually replacing something with something else. So > the basic idea is xml ed -u "..." -x "..." where -u is the r-left and -x is > the r-right values. > > However, it is often difficult to construct an XPath for the r-value in one > statement. I was rather thinking something in the line of : > > xml ed -u "..." -r ...multiple statements... > > In multiple statements we must be able to match (-m), copy (-c), add a tag > (-e), get a value (-v), evaluate an XPath (-x), delete a tag (-d) and maybe > more. Each of these actions are "piped" together as usual, and the result of > the last command will be pasted in the l-value. I dont know what can happen > if you try to replace an attribute with an XML node instead of a value? > > Therefore we could do something like: > > xml ed -u "..." -r -m "/Record/Number" -v "node()" -x "some XPath that adds > 1 to the -v" ... > > This example is obvisouly overkill for what it does. > > Daniel Shane > > ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ xmlstar-devel mailing list xml...@li... https://lists.sourceforge.net/lists/listinfo/xmlstar-devel |