Project

Profile

Help

Bug #6652

closed

parse-xml fails if the string its parsing begins with a BOM

Added by Norm Tovey-Walsh 6 days ago. Updated 6 days ago.

Status:
Resolved
Priority:
Low
Assignee:
Category:
External resources
Sprint/Milestone:
-
Start date:
2025-01-16
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
12, trunk
Fix Committed on Branch:
12, trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

Description

For example:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                exclude-result-prefixes="xs"
                version="3.0">

<xsl:output method="xml" encoding="utf-8" indent="no"/>

<xsl:template match="/" name="xsl:initial-template">
  <xsl:variable name="root" as="element()"><root/></xsl:variable>
  <xsl:sequence select='parse-xml(serialize($root, map{"byte-order-mark": true()}))'/>
</xsl:template>

</xsl:stylesheet>

This is contrived, but a real world example of getting a text/plain response from a web service and discovering a BOM at the beginning has been reported.

Actions #1

Updated by Michael Kay 6 days ago

  • Status changed from New to In Progress

Added QT4 test cases parse-xml-018 and parse-xml-fragment-026

Rather surprisingly, parse-xml fails but parse-xml-fragment succeeds, despite both using the same parser. But I will change both to strip off the BOM prior to parsing.

Actions #2

Updated by Michael Kay 6 days ago

  • Category set to External resources
  • Status changed from In Progress to Resolved
  • Assignee set to Michael Kay
  • Applies to branch 12, trunk added
  • Fix Committed on Branch 12, trunk added
  • Platforms .NET, Java added

Please register to edit this issue

Also available in: Atom PDF