Paul
Paul

Reputation: 1455

XSLT transformation results in characters at the beginning of the document

Hi I have an xml doc like

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfApiFeedProduct xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <ApiFeedProduct>
      <Code>C119X</Code>
      <OfferCode>MJF*Q*MJ*13</OfferCode>
      <ProductType>Straight</ProductType>
      <Title>Joseph Perrier Cuvée Royale Brut Champagne</Title>
      <SDesc>Joseph Perrier Cuvée Royale Brut Champagne</SDesc>...

And an XSLT doc like

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <add>
      <xsl:for-each select="ArrayOfApiFeedProduct/ApiFeedProduct">
        <doc>
          <field name="code">
            <xsl:value-of select="Code"/>
          </field>
          <field name="offercode">
            <xsl:value-of select="OfferCode"/>
          </field>
          <field name="producttype">
            <xsl:value-of select="ProductType"/>
          </field>
          <field name="title">
            <xsl:value-of select="Title"/>
          </field>
          <field name="sdesc">
            <xsl:value-of select="SDesc"/>
          </field>...

But this results in an xml document like

��<?xml version="1.0" encoding="utf-8"?>
<add>
<doc>
<field name="code">C119X</field>
<field name="offercode">MJF*Q*MJ*13</field>
<field name="producttype">Straight</field>
<field name="title">Joseph Perrier Cuvée Royale Brut Champagne</field>
<field name="sdesc">Joseph Perrier Cuvée Royale Brut Champagne</field>...

Where do the first two characters come from?? i.e. ��?

Upvotes: 1

Views: 40

Answers (1)

G. Ken Holman
G. Ken Holman

Reputation: 4403

I suspect they make up the Unicode Byte Order Mark (BOM) encoded as UTF-8. If your document is considered well-formed by a conforming XML processor, then that likely guarantees it, as any other characters before the XML Declaration would render the file not well-formed.

Upvotes: 1

Related Questions