I am using Microsoft's XSLT processor to process a block of XML. I need to break into a series of subnodes using XSLT 1.0.
The input is very regular and of the form "###, ##:##> user text" I think I should be able to use that leading number and the time as some type of marker / delimiter.
An example might be:
<xmldocument>
<Notes>422, 10:06> Test Note 1 422, 10:03> Test Note 2 </Notes>
</xmldocument>
In this case there are 2 notes:
- 422, 10:06> Test Note 1
- 422, 10:03> Test Note 2
The leading number can and will vary. So, it can't be used as a delimiter. I THINK one can use the comma and the greater than to locate the message.
The desired output is:
<xmldocument>
<Notes>
<Note>
<NoteTime>10:06</NoteTime>
<NoteText>Test Note 1 (422)</NoteText>
</Note>
<Note>
<NoteTime>10:03</NoteTime>
<NoteText>Test Note 2 (422)</NoteText>
</Note>
</Notes>
</xmldocument>
An example with one note:
<xmldocument>
<Notes>999, 10:06> Test Note 1</Notes>
</xmldocument>
Would yield:
<xmldocument>
<Notes>
<Note>
<NoteTime>10:06</NoteTime>
<NoteText>Test Note 1 (999)</NoteText>
</Note>
</Notes>
</xmldocument>
And an example with 3 notes:
<xmldocument>
<Notes>999, 10:06> Test Note 1 123, 10:08> Test Note 2 456, 10:10> Test Note 3</Notes>
</xmldocument>
Would yield:
<xmldocument>
<Notes>
<Note>
<NoteTime>10:06</NoteTime>
<NoteText>Test Note 1 (999)</NoteText>
</Note>
<Note>
<NoteTime>10:08</NoteTime>
<NoteText>Test Note 2 (123)</NoteText>
</Note>
<Note>
<NoteTime>10:10</NoteTime>
<NoteText>Test Note 2 (456)</NoteText>
</Note>
</Notes>
</xmldocument>
I guess I could do it with something like this but it seems to me that I shouldn't have to add that level complexity to do this.