- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Ampersand in string literal of XML node.
Thu, 2011-06-23, 21:47
#2
Re: Ampersand in string literal of XML node.
So if I use:
Then I actually get the right thing but it doesn't scan well from a
templating point of view.
Any chance this could be fixed or is it invalid XML?
On Jun 23, 2:26 pm, Tim Stokes wrote:
> If I turn it into a special character then it compiles.
>
> val link =
>
> But that doesn't help me.
>
> Is this a bug?
>
> On Jun 23, 2:23 pm, Tim Stokes wrote:
>
>
>
>
>
>
>
> > Why can't I have this?
>
> > val link =
>
> > The compiler does not like the ampersand in the string.
Thu, 2011-06-23, 21:57
#3
Re: Re: Ampersand in string literal of XML node.
See http://www.w3schools.com/XML/xml_validator.asp
What do you mean by "it doesn't scan well"?
On Jun 23, 2011, at 2:30 PM, Tim Stokes wrote:
> So if I use:
>
> val link =
>
> Then I actually get the right thing but it doesn't scan well from a
> templating point of view.
>
> Any chance this could be fixed or is it invalid XML?
>
> On Jun 23, 2:26 pm, Tim Stokes wrote:
>> If I turn it into a special character then it compiles.
>>
>> val link =
>>
>> But that doesn't help me.
>>
>> Is this a bug?
>>
>> On Jun 23, 2:23 pm, Tim Stokes wrote:
>>
>>
>>
>>
>>
>>
>>
>>> Why can't I have this?
>>
>>> val link =
>>
>>> The compiler does not like the ampersand in the string.
Erik Peterson
m: (281) 804-9023
ep@ardec.com
Thu, 2011-06-23, 22:17
#4
Re: Re: Ampersand in string literal of XML node.
I mean it doesn't read easily for people who are used to seeing just '&'
On 23 June 2011 14:46, coach3pete wrote:
> Invalid:
>
>
> Valid:
>
>
> See http://www.w3schools.com/XML/xml_validator.asp
>
> What do you mean by "it doesn't scan well"?
>
>
> On Jun 23, 2011, at 2:30 PM, Tim Stokes wrote:
>
>> So if I use:
>>
>> val link =
>>
>> Then I actually get the right thing but it doesn't scan well from a
>> templating point of view.
>>
>> Any chance this could be fixed or is it invalid XML?
>>
>> On Jun 23, 2:26 pm, Tim Stokes wrote:
>>> If I turn it into a special character then it compiles.
>>>
>>> val link =
>>>
>>> But that doesn't help me.
>>>
>>> Is this a bug?
>>>
>>> On Jun 23, 2:23 pm, Tim Stokes wrote:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>> Why can't I have this?
>>>
>>>> val link =
>>>
>>>> The compiler does not like the ampersand in the string.
>
> Erik Peterson
> m: (281) 804-9023
> ep@ardec.com
>
>
>
>
Thu, 2011-06-23, 22:27
#5
Re: Ampersand in string literal of XML node.
That's why it's generally a good idea to avoid & for separation of
parameters. If you control the application, better choose ; or something
else (which is recommended by the W3C IIRC).
Thu, 2011-06-23, 22:37
#6
Re: Ampersand in string literal of XML node.
On 06/23/11 16:23, Tim Stokes wrote:
> Why can't I have this?
>
> val link =
>
> The compiler does not like the ampersand in the string.
It's not valid XML.
Compare the following quote from section 2.4 from the xml spec:
"The ampersand character (&) and the left angle bracket (<) MUST NOT appear in
their literal form, except when used as markup delimiters, or within a
comment, a processing instruction, or a CDATA section. If they are needed
elsewhere, they MUST be escaped using either numeric character references or
the strings " & " and " < " respectively. The right angle bracket (>)
may be represented using the string " > ", and MUST, for compatibility, be
escaped using either " > " or a character reference when it appears in the
string " ]]> " in content, when that string is not marking the end of a CDATA
section."
from: http://www.w3.org/TR/2008/REC-xml-20081126/#syntax
I know it sucks, but so does XML.
Have a great existence,
-Martin
Thu, 2011-06-23, 22:47
#7
Re: Re: Ampersand in string literal of XML node.
I guessing a bit without knowing more context...but have you seen scalate for templating?
http://scalate.fusesource.org/documentation/jade.html
If you want something directly in a scala api consider creating a "searchLinkBuilder" using a case class with named params...or a fluent api: http://stackoverflow.com/questions/6347083/type-safe-builder-library-for...
On Jun 23, 2011, at 3:09 PM, Tim Stokes wrote:
> I mean it doesn't read easily for people who are used to seeing just '&'
>
> On 23 June 2011 14:46, coach3pete wrote:
>> Invalid:
>>
>>
>> Valid:
>>
>>
>> See http://www.w3schools.com/XML/xml_validator.asp
>>
>> What do you mean by "it doesn't scan well"?
>>
>>
>> On Jun 23, 2011, at 2:30 PM, Tim Stokes wrote:
>>
>>> So if I use:
>>>
>>> val link =
>>>
>>> Then I actually get the right thing but it doesn't scan well from a
>>> templating point of view.
>>>
>>> Any chance this could be fixed or is it invalid XML?
>>>
>>> On Jun 23, 2:26 pm, Tim Stokes wrote:
>>>> If I turn it into a special character then it compiles.
>>>>
>>>> val link =
>>>>
>>>> But that doesn't help me.
>>>>
>>>> Is this a bug?
>>>>
>>>> On Jun 23, 2:23 pm, Tim Stokes wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> Why can't I have this?
>>>>
>>>>> val link =
>>>>
>>>>> The compiler does not like the ampersand in the string.
>>
If I turn it into a special character then it compiles.
val link =
But that doesn't help me.
Is this a bug?
On Jun 23, 2:23 pm, Tim Stokes wrote:
> Why can't I have this?
>
> val link =
>
> The compiler does not like the ampersand in the string.