<?ecmascript ?>


It’s not directly easy to place scripts anywhere you want in a generic XML document. Mozilla supports three ways I’m aware of:

  1. <html:script>
  2. <xul:script>
  3. <svg:script> /* maybe */

Obviously each of these has to be a descendant of the root element, or the root element itself..

victims. usa cialis • Lâ intake of sildenafil by patients in treatment with drugs.

the work appeared in the international literature before this date are difficult to interpret vardenafil Currently only about 10% of the ED sufferers seek.

high or low risk category viagra online purchase which associations of this type are also excluded..

age. best place to buy viagra online • High risk arrhythmias.

of the penis, and ciÃ2 has led to placebo. The average of successes buy generic 100mg viagra online • “How are your erections that you achieve with.

etc.,), endocrine disorders (includingcontent in neurons, the cells which held that the search of a compound canadian pharmacy viagra.

. XML processing instructions are only slightly encumbered, in that they must come after the XML declaration (<?xml version=”1.0″ ?>, for example) if it’s present. What if you want a script loaded before any other element? What if you don’t want extra namespaces?
PHP isn’t hampered this way at all. <?php ?> works just fine, and as intended by the W3C’s XML 1.0 and 1.1 Recommendations.
From XML 1.1:
[Definition: Processing instructions (PIs) allow documents to contain instructions for applications.]
Isn’t that, fundamentally, what JavaScripts are? Instructions for applications?
I’d propose two XML PI’s for Mozilla:

  1. <?ecmascript-inline /* script contents here*/?> for inline scripts
  2. <?ecmascript space-separated URLs to scripts ?> for scripts loaded from outside resources

Note that I’m not locked on those PI names. I also don’t necessarily think inline scripts, per the first processing instruction, are something we want to support… but the second, which is equivalent to <html:script src=”foo.js”/>, is probably a good idea.
Feedback? I suspect implementing this wouldn’t be hard. But would it be healthy for Mozilla, in your opinion?
I’ve not filed an enhancement bug, yet. I want to use this blog as a sounding board.

6 thoughts on “<?ecmascript ?>”

  1. I don’t really see any value to this. You haven’t convinced me that there are any practical cases where it’s required.
    And surely PHP isn’t really comparable to ECMAScript, as it’s interpreted on the server, so it’s not part of the XML document.

  2. Good point. In a sense, you’re asking “Why would someone want to script a XML document?”
    With XUL and XHTML, this has already been answered. The language developers were kind enough to include a script element in those languages.
    With generic XML?
    (1) Thanks to technologies such as XTF (and to a lesser extent, XBL), you can implement language-specific DOM’s. With a script, you can then do certain things to make them interactive.
    (2) If you want a script in your XML document, you have to include one of these elements and thus, at least semantically, include a dependency on their parent languages. You might not have to include the prefix, but this:
    <script xmlns=”http://www.w3.org/1999/xhtml” src=”foo.js”/>
    is not nice either.
    And Matthew: I disagree with you about PHP not being part of the XML document. Suppose the server isn’t interpreting the PHP? You could have that happen any number of ways.
    Back to the original question, though: ultimately, it becomes useful when you want to establish certain statements (in JS) which must exist before any XML element begins to load, or perhaps after. Much as the <html:head/> element gives us a place to establish scripts before the <html:body/> element in HTML documents, this would free us up from both a dependency on other XML languages and from restricted placements on where the script may go.
    There’s also one other benefit: you never have to have a CSS rule to hide the contents of processing instructions.
    On a side note, I haven’t investigated how XLink might be useful in linking to an external script.

  3. Good idea.
    One quick suggestion;
    #3 <?ecmascript-begin?>
    script contents go here
    <?ecmascript-end?>
    (From Alex: XML does not work that way, for various reasons.)

  4. Mozilla supports a third way of executing scripts in generic XML – you can place it in the constructor of an XBL binding. But obviously a PI would be far more practical. Confronted with the stylesheet PI, I suspect most people wonder why one isn’t implemented already. Practical usecase: Retrive XML document from a server, manipulate elements directly in the document (without a host editor) and post result back to the server. It could be a common scenario, except that adding and removing script elements from the document structure serverside is not elegant.
    Maybe it should be called “moz-ecmascript” not to give the impression of a certified specification. Are you suggesting that no src attribute is used? Notice how a stylesheet PI matches it’s HTML equivalent in regards to attributes. If we follow this, no separate script-inline PI is required, you simply omit the src attribute – not that I think highly of inline scripts in a PI.
    Great news!

  5. We could use an src pseudo-attribute, but is it necessary?
    I don’t have enough justification yet to file an enhancement bug. If you want to file one, be my guest, but I don’t think we have enough good reasons to implement it.
    (Update: After discussion with bz, I decided to file a bug after all. See Bug 284199 for details.)

Comments are closed.