Plugin development - Accessing text nodes via AuthorElement
Posted: Wed Jul 30, 2008 1:08 am
Hi there. I'm developing a plugin for use within the author perspective that will drop in a chunk of empty xml nodes that the user will then populate with data. What I'm trying to do is populate one of those empty xml nodes by determining the value of the previous sibling's text node where the node's names are equal, such that I can automatically populate one of the tags I'm inserting with an incremented value. -- I know that may not be very clear, so here's an example...
--existing xml--
<para>
<paraNum>1</paraNum>
<paraText>Some text</paraText>
</para>
<note>
<noteText>Some note text</note>
</note>
-- end existing xml--
--xml after plugin has run inserting a new "para" while the carrot focus is on the noteText--
<para>
<paraNum>1</paraNum>
<paraText>Some text</paraText>
</para>
<note>
<noteText>Some note text</note>
</note>
<para>
<paraNum>2</paraNum>
<paraText/>
</para>
----------------
The problem I'm having is determining the value of the previous <paraNum>'s value. I've written a serializer that takes the AuthorDocument from the AuthorNode.getOwnerDocument, and I'm attempting to create an in memory xmlDocument to xPath out the desired node. I'm thinking this is not the best way to go about it, but I'm at a loss as to how to proceed.
Any advice or direction would be greatly appreciated.
Thanks.
Cal.
--existing xml--
<para>
<paraNum>1</paraNum>
<paraText>Some text</paraText>
</para>
<note>
<noteText>Some note text</note>
</note>
-- end existing xml--
--xml after plugin has run inserting a new "para" while the carrot focus is on the noteText--
<para>
<paraNum>1</paraNum>
<paraText>Some text</paraText>
</para>
<note>
<noteText>Some note text</note>
</note>
<para>
<paraNum>2</paraNum>
<paraText/>
</para>
----------------
The problem I'm having is determining the value of the previous <paraNum>'s value. I've written a serializer that takes the AuthorDocument from the AuthorNode.getOwnerDocument, and I'm attempting to create an in memory xmlDocument to xPath out the desired node. I'm thinking this is not the best way to go about it, but I'm at a loss as to how to proceed.
Any advice or direction would be greatly appreciated.
Thanks.
Cal.