@@ -676,7 +676,7 @@ func TestLineNumbers(t *testing.T) {
676676 <price>29.99</price>
677677</book>
678678</bookstore>`
679-
679+
680680 doc , err := ParseWithOptions (strings .NewReader (s ), ParserOptions {WithLineNumbers : true })
681681 if err != nil {
682682 t .Fatal (err )
@@ -723,3 +723,31 @@ func TestLineNumbers(t *testing.T) {
723723 t .Errorf ("title should be on line 6, got line %d" , title .LineNumber )
724724 }
725725}
726+
727+ func TestProcessingInstructionStructure (t * testing.T ) {
728+ t .Run ("Document1" , func (t * testing.T ) {
729+ xml := `<?xml version="1.0" encoding="UTF-8"?><item><para>first</para><?xe-change-remove-start?><item><para>second</para></item></item>`
730+ doc , err := Parse (strings .NewReader (xml ))
731+ if err != nil {
732+ t .Fatalf ("Failed to parse document1: %v" , err )
733+ }
734+
735+ output := doc .OutputXML (false )
736+ if output != xml {
737+ t .Errorf ("Document1 output mismatch:\n Expected: %s\n Got: %s" , xml , output )
738+ }
739+ })
740+
741+ t .Run ("Document2" , func (t * testing.T ) {
742+ xml := `<?xml version="1.0" encoding="UTF-8"?><list><item><para><?xe-change-remove-start?></para></item></list>`
743+ doc , err := Parse (strings .NewReader (xml ))
744+ if err != nil {
745+ t .Fatalf ("Failed to parse document2: %v" , err )
746+ }
747+
748+ output := doc .OutputXML (false )
749+ if output != xml {
750+ t .Errorf ("Document2 output mismatch:\n Expected: %s\n Got: %s" , xml , output )
751+ }
752+ })
753+ }
0 commit comments