How can XSLT stylesheets be used to edit, remove and add nodes specified
by their position in the document tree?
The XML document stores development tasks in a hierarchical way, i.e.
tasks can have subtasks, subsubtasks, etc. It has the following form:
<todo>
<note>Task 1</note>
<note>
Task 2
<note>
Task 2.1
</note>
<note>
Task 2.2
</note>
</note>
<note>Task 3</note>
</todo>
The aim is to implement a web interface for task management in
development projects, using parameterised XSLT stylesheets, and some cgi
scripts invoking an XSLT processor to modify the task database.
Is this choice of technologies sensible, or are there better ways to
operate on the XML document?
The stylesheets would be passed the position of the node in the document
tree, i.e. "2.2" would refer to the second subtask of the second task in
the todo list. This node would be removed or edited, or become the
parent of a new subtask (`add').
Can you give me some tips or pointers on how to add, remove and edit
nodes?
I got as far as the following for removing nodes. Of course, this would
need to be negated in some form to remove the corresponding node.
========================XSL======================= =======
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:copy-of select="todo/note[2]/note[2]"/>
</xsl:template>
</xsl:stylesheet>
========================XSL======================= =======
tia,
Claudio
PS. The XML format originates from the software package devtodo, which
is provides an interactive command-line based interface to the XML
database.
http://swapoff.org/DevTodo
--
http://www.jolowicz.com