Instructions like xsl:for-each and xsl:apply-templates always process nodes in document order, regardless of the XPath expression that was used to locate the nodes. However, predicates like [1] consider the nodes in axis order, so preceding-sibling::*[1] is the immediately preceding sibling.
Parsing the content of your processing instructions will be much easier if you use XSLT 2.0, which gives you regular expression support. String manipulation can be done in XSLT 1.0, but it's a pain.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference