+ Reply to Thread
Results 1 to 4 of 4

Thread: <br/> XML literal in code

  1. #1

    Default <br/> XML literal in code

    Hi,

    once I've learned how used XML literals in code segments in templates I enjoyed them (although the code looks like real mess :-).
    Now strange thing happens - I've all different XML tags in the code , but for some strange reason reason I cannot get there <br/> tag.

    Code:
    <p>
    "Bla"
    <br/>
    "Bla"
    </p>
    gives this error: pre, line 3, column 4: invalid XmlNode

    and

    Code:
    <p>
    "Bla"
    <br></br>
    "Bla"
    </p>
    gives other error: pre, line 3, column 5: invalid Primary.

    I'm on Lyons - what could be wrong?

  2. #2
    Join Date
    Nov 2008
    Location
    Ludington, Mi (USA)
    Posts
    751

    Default

    Quote Originally Posted by ivan.zderadicka View Post
    Hi,

    once I've learned how used XML literals in code segments in templates I enjoyed them (although the code looks like real mess :-).
    Now strange thing happens - I've all different XML tags in the code , but for some strange reason reason I cannot get there <br/> tag.

    Code:
    <p>
    "Bla"
    <br/>
    "Bla"
    </p>
    gives this error: pre, line 3, column 4: invalid XmlNode

    and

    Code:
    <p>
    "Bla"
    <br></br>
    "Bla"
    </p>
    gives other error: pre, line 3, column 5: invalid Primary.

    I'm on Lyons - what could be wrong?


    Try terminating the string lines (that are not valid xml nodes with the semi-colon ";" like this.

    Code:
    <p>
    "Bla";
    <br></br>
    "Bla";
    </p>
    We are more ready to try the untried when what we do is inconsequential. Hence the fact that many inventions had their birth as toys. - Eric Hoffer

  3. #3
    Join Date
    Mar 2008
    Posts
    1,630

    Default

    Rberinger is of course correct; I'll just add that the literal <br /> works fine (I use it all the time), as long as you get the semicolons straight. This is a pitfall I plan to cover in the Beginner's Guide to Dekiscript.

    Here's how to think about XML literals correctly, to avoid problems in the future:
    1) Nothing has changed the fact that your script is a series of statements or expressions separate by semicolons. XML literals just happen to be fancy expressions that can have additional embedded DekiScript.
    2) The contents of an XML literal element must be valid DekiScript. Therefore, if you have
    Code:
    <p>
    "Blah"
    <br />
    "Blah"
    </p>
    Then the contents of the <p> literal is really the following script:
    Code:
    "Blah" <br /> "Blah"
    This clearly is not valid; you can never have a series of values separated by spaces. By inserting the semicolons, you're turning it into a series of statements, each returning a single value. That's a valid script.

    I'm still working on the best way to convey this clearly; what I've given you here is representative of my current thinking. Please let me know if this gives you any useful insight.

  4. #4
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    To add to rberinger's and neilw's explanations, you can only omit the semi-colon ( on the very last statement of a code block.
    For example:
    Code:
    {{ a; b; c }}
    We allowed the omission of the semi-colon in some cases to make the trivial case easier, namely {{ a }}. Unfortunately, it also leads to confusion when and where you can omit them.
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts