Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You cannot use the characters '{' and '|' directly in id attributes because in the <a href="http://www.w3.org/TR/xml/" rel="nofollow">XML specification</a> it says</p> <blockquote> <p>Values of type ID must match the Name production. A name must not appear more than once in an XML document as a value of this type; i.e., ID values must uniquely identify the elements which bear them.</p> </blockquote> <p>The name production is <a href="http://www.w3.org/TR/xml/#NT-Name" rel="nofollow">here</a>. If you expand the syntax rule you see that the only characters allowed in a name are given by these productions:</p> <blockquote> <p>[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]</p> <p>[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]</p> </blockquote> <p>Unfortunately the left brace and the pipe are not allowed. The codepoints for those characters are #7B and #7C respectively; not in the accepted character ranges.</p> <p>TL;DR: the legal characters for ID attributes are owned by the XML spec and your two characters are not legal.</p> <p><strong>ADDENDUM</strong></p> <p>Here are some examples. The following document passes validation for XHTML on the W3C validation site:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"&gt; &lt;head&gt; &lt;title&gt;A title&lt;/title&gt; &lt;/head&gt; &lt;body id="anid"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>but the following will not</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"&gt; &lt;head&gt; &lt;title&gt;A title&lt;/title&gt; &lt;/head&gt; &lt;body id="ani{d"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>We get the error:</p> <pre><code>Line 8, Column 16: character "{" is not allowed in the value of attribute "id" </code></pre> <p>Now it's rather interesting that if you really want the left curly bracket in the id name, you can <em>try</em> this:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"&gt; &lt;head&gt; &lt;title&gt;A title&lt;/title&gt; &lt;/head&gt; &lt;body id="ani&amp;#x7B;d"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>But you get the <em>same</em> error! You might want to try this; the validator shows the line with the ampersand hash x seven b semicolon but it thinks there is a left brace there.</p> <p>The bottom line is that you simply <strong>cannot</strong> have ids with characters other than those allowed by the XML specification.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload