I have something like the following xml (this is not actually it the dataset is FAR larger):
<people>
<!-- People start here -->
<person>
<name>Sara</name>
<age>27</age>
</person>
<person>
<name>Carl</name>
<age>25</age>
</person>
<!-- Nick is the father -->
<person>
<name>Nick</name>
<age>52</age>
</person>
</people>
and I have written an XSL to add a line to all of the person, imagine person now has to look like:
<person>
<name>Sara</name>
<age>27</age>
<gender>female</gender>
</person>
However I still want to keep the comments but some have comments after the end node and some do not. I have tried many angles but I don't know how to check if the preceding node is a comment or not. None of the following have worked:
- preceding-sibling::comment()[1] (if there is ever one comment it will always get this)
- preceding-sibling::* (doesn't pick up comments)
- preceding::* (doesn't pick up comments)
I kind of need to look at the preceding node and check if it is of type case if it is continue if not the grab the comment and spit it out. Maybe I have to work out the node position in the whole document (how?) and then check the preceding node that way? It is not necessary for this to be efficient.
Thanks