The reference to entity "subset" must end with the ';' delimiter [duplicate]
Asked Answered
M

2

16

I am trying to include webfonts in the template of a Blogger blog:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html b:version='2' class='v2' expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>
  <head>
    <link href='http://fonts.googleapis.com/css?family=Share:400,700&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Istok+Web:400,700&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
    <meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/>
    <b:if cond='data:blog.isMobile'>
      <meta content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0' name='viewport'/>
    <b:else/>

And when I try to save the template, I get:

Error parsing XML, line 5, column 76: The reference to entity "subset" must end with the ';' delimiter.

I tried to add a ; but unsuccessfully. The links are generated and taken from Google Web Font.

How should I solve this issue? Thanks.

Momentum answered 1/1, 2013 at 16:57 Comment(0)
C
53

That's because & is a reserved character in XML that means "an XML entity begins here". XML entities let you print characters or sequences of characters that are hard for you to embed in your document literally, either because you don't have it on your keyboard or because the document encoding forbids it. For instance, in (X)HTML, &eacute; prints the character "é", which is not easy to find on most US keyboard. (Available entities depend on the <!DOCTYPE> declaration of your XML document.)

The problem with that scheme is that it means you can't unambiguously leave literal & characters around your document if they can be the start of an entity, so you need to encode them as an entity to solve that problem.

You will need to replace all your stray & with &amp;, which will print & without angering the XML parser. In your case, you should be good with replacing &subset= by &amp;subset= in your two <link> tags.

Crusted answered 1/1, 2013 at 17:3 Comment(0)
S
6

Ampersands in XML indicate the start of an entity reference. It starts with an ampersand, then there's a marker indicating which entity it is referring to, then a semicolon to end it. In order to include a literal ampersand in a document, you need to use a character entity reference that refers to an ampersand, i.e. &amp;.

As you have not done this, the parser is trying to parse the following data as if it were an entity reference, which it is not. That is why it fails to parse - it can't find the semi-colon at the end of the entity reference because it's not supposed to be an entity reference.

For instance, where you have:

http://fonts.googleapis.com/css?family=Share:400,700&subset=latin,latin-ext

You should have:

http://fonts.googleapis.com/css?family=Share:400,700&amp;subset=latin,latin-ext
Sapor answered 1/1, 2013 at 17:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.