# File: laszlo.rnc # Author: Oliver Steele # # lzx.rnc is in the RELAXNG Compact syntax: # http://www.thaiopensource.com/relaxng/compact/syntax.html # # lzx.rng is a RELAXNG schema: # http://www.oasis-open.org/committees/relax-ng/ # * P_LZ_COPYRIGHT_BEGIN ****************************************************** # * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. * # * Use is subject to license terms. * # * P_LZ_COPYRIGHT_END ******************************************************** #default namespace = "http://www.laszlosystems.com/2003/05/lzx" namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0" namespace lza = "http://www.laszlosystems.com/annotations/1.0" namespace rng = "http://relaxng.org/ns/structure/1.0" # Literals booleanLiteral = xsd:boolean colorLiteral = string numberLiteral = xsd:double sizeLiteral = xsd:double { minInclusive = "0" } constraint = xsd:string { pattern = "$(immediately|once|always)?\{.*\}" } # Attribute value types boolean = booleanLiteral | constraint color = colorLiteral | constraint script = string expression = string reference = string number = numberLiteral | constraint size = sizeLiteral | constraint numberExpression = string sizeExpression = string css = string opacity = xsd:double { minInclusive = "0.0" maxInclusive = "1.0" } | constraint # Grammar start = canvas | viewElement | library canvas = ## The canvas is the container for all views within an application. element canvas { idAttribute? & oninitAttribute? & ## The width of the canvas. [ a:defaultValue = "800" ] attribute width { sizeLiteral }? & ## The height of the canvas. [ a:defaultValue = "600" ] attribute height { sizeLiteral }? & ## The background color of the canvas. [ a:defaultValue = "white" ] attribute bgcolor { colorLiteral }? & ## The string that is used in the browser window. [ a:defaultValue = "Laszlo Application" ] attribute title { string }? & ## The default font for views in this application. [ a:defaultValue = "lztahoe8" ] attribute font { string }? & ## The default size for views in this application. [ a:defaultValue = "8" ] attribute fontsize { size }? & ## The default font style for views in this application. The empty string ## is interpreted as 'plain'. [ a:defaultValue = "" ] attribute fontstyle { "bold" | "italic" | "bold italic" | "plain" | "" }? & attribute layout { css }? & ## If false, disables validation against the schema during compilation [ a:defaultValue = "true" ] attribute validate { booleanLiteral }? & ## If true, the application is compiled in debug mode, and a ## debugger window will appear when the application is loaded. ## Runtime errors (calls to undefined methods or function ## functions, references to undefined properties or variables) are ## detected and logged to the debugger window. (Note: debug ## mode may cause the application to run more slowly, even if the ## debugger window is not visible.) Debug mode can also be enabled at ## runtime by loading the application using the @c{?debug=true} ## option. [ a:defaultValue = "false" ] attribute debug { booleanLiteral }? & ## If present, specifies the maximum width in pixels of any output text field. ## Text which extends beyond this width will be clipped. ## If this attribute is omitted, it defaults to the canvas width. attribute maxtextwidth { sizeLiteral }? & ## If present, specifies the maximum height in pixels of any output text field. ## Text which extends beyond this height will be clipped. ## If this attribute is omitted, it defaults to the canvas height. attribute maxtextheight { sizeLiteral }? & ## A list of names for libraries that are included in the application. [ a:defaultValue = "" ] attribute libraries { string }? & connection? & splash? & datapathChildren & toplevelElements & ## The lpsversion of this lzx application. [ a:defaultValue = "1.1" ] attribute version { string }? } library = element library { (toplevelElements & datapointer*) } toplevelElements = (viewElement | scriptElement | asset | font)* & datasource* & connectiondatasource* & dataset* & debugger? & command* & objectElements & class* & includeElement* & library* & layout* debugger = ## The debug element specifies the attributes of the runtime ## debugger. This element only takes effect if either the ## @c{canvas} @a{debug} attribute is true or the application is ## loaded using the @c{?debug=true} option. [ lza:since = "1.1" ] element debug { ## The width of the debugger window. [ a:defaultValue = "325" ] attribute width { size }? & ## The height of the debugger window. [ a:defaultValue = "125" ] attribute height { size }? & ## The x position of the debugger window. [ a:defaultValue = "10" ] attribute x { numberExpression }? & ## The y position of the debugger window. [ a:defaultValue = "10" ] attribute y { numberExpression }? & ## The debugger window font [ a:defaultValue = "debugger-font" ] attribute font { string }? & ## The point size of the font [ a:defaultValue = "8" ] attribute fontsize { size }? } includeElement = element include { ## A reference to a target file whose content is included in the ## application that contains this include element. attribute href { xsd:anyURI } & ## If this attribute has the value @c{text}, the content of the ## target file is included as text. Otherwise, it is read as XML. [ a:defaultValue = "xml" ] attribute type { "text" | "xml" }? } # # Attributes # idAttribute = ## A unique identifier for this element. Can be used as a global ## variable name in JavaScript code. [ lza:modifiers = "final" ] attribute id { xsd:ID } srcAttribute = ## The path of a file that contains the source for this object. [ lza:modifiers = "final" ] attribute src { xsd:anyURI } nameAttribute = ## The name of a variable that will be set to this object when the ## application is started. If this element is directly within a ## @e{canvas} or @e{library} element, the global variable and the canvas ## property with this name will be set to this object. If this ## element is within another object, that object's property with ## this name will be set to this object. [ lza:modifiers = "final" ] attribute name { token } oninitAttribute = ## The oninit script is executed once, after the element's ## children, if any, have been initialized. attribute oninit { script } objectAttributes = idAttribute?, nameAttribute?, oninitAttribute?, ## The execution of a @c{}'s @c{init} method and sending of ## the @c{oninit} event is under the control of its @a{initstage} ## attribute, as follows: ##
##
@c{immediate}.
The @c{init} method is called immediately as the ## last stage of @a{instantiation}. ##
##
@c{early}.
The @c{init} method is called immediately after the ## view and its children have been @a{instantiated}. ##
##
@c{normal}.
The @c{init} method is called when the parent is ## @a{initialized}. ##
##
@c{late}.
The @c{init} method is called during idle time. ## To check whether @c{init} has been called, check the @c{isinited} ## property. Force calling @c{init} using the ## @c{completeInstantiation} method. ##
##
@c{defer}.
The @c{init} method will not be called unless ## explicitly requested by the @c{completeInstantation} method. ##
##
[ a:defaultValue = "normal" lza:modifiers = "final" ] attribute initstage { "early" | "normal" | "late" | "immediate" | "defer" }?, ## Specifies the data source for this node and its children. ## If the value begins with an identifier followed by a colon, the ## identifier names a dataset, and the portion of the string after ## the colon is an XPath description of a portion of the data. ## Otherwise the entire attribute value is an XPath description of ## the data, relative to the data source of this node's parent element. ## Examples: "mydata:", "mydata:/a/b", "/a/b". attribute datapath { string }? viewAttributes = objectAttributes, ## The opacity of the view's contents. @c{1.0} is opaque; @c{0.0} is ## totally transparent (invisible). [ a:defaultValue = "1.0" ] attribute opacity { opacity }?, attribute bgcolor { color }?, ## The cursor to display when the mouse is over this view. Any ## resource can be used as a cursor. This attribute can be set for ## any view with clickable=true, or any view whose class defaults ## clickable to true. attribute cursor { token }?, ## If true, this view intercepts click events; otherwise they are passed ## to its container. This defaults to true if the view defines a mouse ## event handler or a cursor. attribute clickable { boolean }?, ## If true, this view "traps" the focus, for example in a window or dialog. ## See focus manager (LzFocus) for more details. attribute focustrap { boolean }?, ## If true, this view will receive focus events. ## See focus manager (LzFocus) for more details. attribute focusable { boolean }?, ## If this view has a multi-frame resource, this allows setting which ## resource frame is displayed. Defaults to the first frame (1). [ a:defaultValue = "0" ] attribute frame { number }?, ## A color to use to render object that appears inside this view, ## which includes any vector or bitmap art in the view's resource ## and any contained views. attribute fgcolor { color }?, ## The font to use for any @c{} or @c{} elements that ## appear inside this view. Like all the font properties ## (fontstyle and fontsize too) these ## properties cascade down the view hierarchy until a new value is ## specified. When the font attributes are modified at runtime, ## using JavaScript, the font is changed for the view itself, not ## for any of its subviews. attribute font { string }?, ## The style to use to render text fields that appear inside of ## this view. Once of "plain", "bold" , "italic" or "bolditalic". attribute fontstyle { string }?, ## Pixel size to use to render text which appears inside this ## view. The default is 8. attribute fontsize { size }?, ## A resource that is presented in the background of this view. ## The value can be either the name of a resource defined with @c{}, ## a URL, or a pathname. If the value is a URL, the resource is requested ## when the view is displayed. If it's a pathname, the file named by ## the pathname is compiled into the application, and attached to this view. attribute resource { string }?, ## Clip the view's contents to its size. [ a:defaultValue = "false" lza:modifiers = "final" ] attribute clip { boolean }?, [ a:defaultValue = "left" lza:modifiers = "final" ] attribute align { "left" | "center" | "right" }?, ## Creates a constraint on the view's y position which is a function ## of its height and its parent's height. The default for this is ## "top". [ a:defaultValue = "top" ] attribute valign { "top" | "middle" | "bottom" }?, ## A CSS property: value sequence of layout parameters, which are ## used to create a layout that is attached to this view. If there ## is a class property, it names the class of the layout; otherwise ## simplelayout is used. Examples: "axis: x", "class: constantlayout; ## axis: y"; "axis: x; spacing: 5". ## ##
  ## <view layout="axis:x; spacing:20">
  ##     <view bgcolor="red" width="20" height="20"/>
  ##     <view bgcolor="red" width="20" height="20"/>
  ##     <view bgcolor="red" width="20" height="20" />
  ## </view>
  ## 
[ lza:modifiers = "final" ] attribute layout { css }?, [ lza:modifiers = "final" ] attribute placement { string }?, ## The view system supports sub-pixel positioning to enable smooth ## animation. This may be turned off to make the view snap to a ## pixel boundary by setting pixellock to true. [ a:defaultValue = "false" lza:modifiers = "final" ] attribute pixellock { booleanLiteral }?, [ a:defaultValue = "0" ] attribute rotation { numberExpression }?, ## Specifies whether to present the resource attached to this view. [ a:defaultValue = "0" ] attribute xoffset { numberExpression }?, ## Specifies a translation point for drawing of this view. If the xoffset ## is set, then rotation and x position will be calculated by first adding ## the xoffset. [ a:defaultValue = "0" ] attribute yoffset { numberExpression }?, ## Specifies a translation point for drawing of this view. If the yoffset ## is set, then rotation and y position will be calculated by first adding ## the yoffset. [ a:defaultValue = "true" ] attribute play { boolean }?, # [a:defaultValue="true"] ## For a view that contains multiple elements, specifies whether one ## or more can be selected. attribute selectiontype { "none" | "single" | "toggle" | "multi" | "range" }?, ## Setting stretches causes a view to change its ## coordinate space so that everything it contains (resources and ## other views) fit exactly into the view's width and/or height. The ## default for this property is "none". This is used to resize a ## view's contents by setting its width and/or height. attribute stretches { "width" | "height" | "both" }?, [ a:defaultValue = "true" ] attribute visible { boolean }?, attribute width { sizeExpression }?, attribute height { sizeExpression }?, ## The horizontal offset of this view's upper left corner from the ## upper left corner of its container. [ a:defaultValue = "0" ] attribute x { numberExpression }?, ## The vertical offset of this view's upper left corner from the ## upper left corner of its container [ a:defaultValue = "0" ] attribute y { numberExpression }?, ## The horizontal scaling applied to the view's resource. If xscale ## is set, the view stretches in its x axis. A value of 1 means that ## the resource will be distorted in the horizontal axis. [ a:defaultValue = "1.0" ] attribute xscale { numberExpression }?, ## The vertical scaling applied to the view's resource. If yscale is ## set, the view stretches in its y axis. A value of 1 means that ## the resource will be distorted in the vertical axis. [ a:defaultValue = "1.0" ] attribute yscale { numberExpression }?, ## A list of CSS property names and values that configure the ## behavior of objects, such as data binding and view layouts, that ## operate on this view. [ lza:modifiers = "final" ] attribute options { css }?, eventAttributes eventAttributes = ## The onclick script is executed when the pointing device button is ## clicked over an element. attribute onclick { script }?, ## The ondblclick script is executed when the pointing device button ## is double clicked over an element. attribute ondblclick { script }?, ## The onmousedown script is executed when the pointing device button is ## pressed over an element. attribute onmousedown { script }?, ## The onmouseup script is executed when the pointing device button is ## released over an element. attribute onmouseup { script }?, ## The onmouseover script is executed when the pointing device is ## moved onto an element. attribute onmouseover { script }?, ## The onmouseout script is executed when the point device is moved ## so that is is no longer over an element. attribute onmouseout { script }?, ## The onfocus script is executed when an element receives focus ## either by the pointing device or by tabbing navigation. attribute onfocus { script }?, ## The onblur script is executed when an element loses focus either ## by the pointing device or by tabbing navigation. attribute onblur { script }?, ## The onkeydown script is executed when this view has the focus and ## a key is pressed down. Multiple key down events are sent for a ## key that is held down. If you want the script executed only ## once, use onkeyup. attribute onkeydown { script }?, ## The onkeyup script is executed when this view has the focus and a ## key is released. attribute onkeyup { script }?, attribute onselect { script }?, ## The ondata script is executed when a view's datapath gets new ## data, due either to a change in the dataset or a change in the ## parent datapath. attribute ondata { script }? # # View Content # viewContent = viewAttributes & viewContentElements viewContentElements = objectElements viewContentElements &= includeElement* & datapathChildren & viewElement* & element dataselectionmanager { idAttribute? & nameAttribute? & attribute toggle { boolean }? & oninitAttribute? & objectElements }? & element selectionmanager { idAttribute? & nameAttribute? & attribute toggle { boolean }? & oninitAttribute? & objectElements }* & layout* viewContentElements &= command* command = element command { idAttribute?, nameAttribute?, attribute onselect { script }?, attribute active { boolean }?, attribute key { expression }?, oninitAttribute?, objectElements } animator = ## Animates a view property to a value over a duration. For ## example, @c{} defines a view that fades in over the ## course of a second (1000ms). element animator { animatorContent } animatorgroup = ## Any attribute that is legal in @e{animator} is legal in ## @e{animatorgroup}. These attributes are then cascaded to the ## animators contained within. ## ## Events (such as onstart, onstop, etc.), name, and id, however, are ## not cascaded. Also, "start" defined at the group level is ## effectively cascaded to the animators, meaning that the start ## attribute is ignored in the animators themselves. element animatorgroup { [ a:defaultValue = "sequential" ] attribute process { "sequential" | "simultaneous" }? & animatorContent } animatorContent = idAttribute? & nameAttribute? & oninitAttribute? & objectElements & ## The name of the attribute whose value is animated. This ## attribute is required on an animator, unless the animator is ## inside an animatorgroup that specifies an attribute. attribute attribute { token }? & ## Whether to start the animation instantly (the default), ## or wait for a script command. [ a:defaultValue = "true" ] attribute start { boolean }? & ## The start value for the animation. Defaults to the ## targeted attribute's current value. attribute from { number }? & ## The final value for the targeted attribute. attribute to { number }? & ## The duration of the animation, in milliseconds (1000 = 1 second). attribute duration { xsd:float { minInclusive = "0" } | constraint }? & [ a:since = "1.1" a:defaultValue = "false" ] attribute indirect { boolean }? & ## Whether the to value is relative to the initial value of the ## attribute (@c{true}), or is absolute (@c{false}). [ a:defaultValue = "false" ] attribute relative { boolean }? & [ a:defaultValue = "easeboth" ] attribute motion { "linear" | "easein" | "easeout" | "easeboth" }? & ## Executed when the animator starts. This code is executed ## multiple times if the animator repeats. attribute onstart { script }? & ## Executed when the animator finishes. attribute onstop { script }? & ## The number of times to repeat the animation. This should be a ## positive integer, or 'Infinity'. Changes to the repeat value ## take effect, after the animation is finished and then restarted. [ lza:since = "1.1" ] attribute repeat { xsd:integer { minInclusive = "1" } | "Infinity" | constraint }? & ## The paused state of the animator. If true, the animator will stop. When ## changed to false, the animator will resume from its current location [ a:defaultValue = "false" ] attribute paused { boolean }? # # View elements # viewElement = ## A view is the basic displayable Laszlo object. One view controls ## one displayable resource. The view system is strictly ## hierarchical. A view has a single parent but can have multiple ## children. ## ## The evaluation of a view occurs in three phases: ## ## 1. @a{Construction}. The object representing the view is ## created, and attributes with constant initial values are filled ## in. ## ## 2. @a{Instantiation}. The attributes with dynamic initial values ## are filled in (which includes the @a{construction} and ## @a{instantation} of any child views), the @c{initialize} method ## is executed, and the @c{onconstruct} event is sent. ## ## 3. @a{Initialization}. The @c{init} method is executed and the ## @c{oninit} event is sent. ## ## Note that @a{construction} and @a{instantiation} occur ## sequentially, but that @a{intialization} may be arbitrarily ## delayed, depending on the value of the @a{initstage} attribute. ## Attributes with dynamic initial values may not depend on other ## attributes with dynamic initial values, nor on the @c{initialize} ## or @c{init} methods having been run. element view { viewContent } | ## HTML text. ## ## A text view which is not given an explicit width will default ## to have a width which is the length of the longest line. Given ## that the initial text content is normalized according to HTML ## normalization rules, and if you do not specify an explicit ## width, the only way a linebreak will occur is if you have an ## explicit HTML linebreak code such as @c{
}, @c{

} or a ## newline inside of the text contents of a @c{

} element.
    ## 
    ## The text view will default to a height which encloses all of
    ## the lines of text.
    ## 
    ## If no initial text content is specified, i.e., you have an
    ## empty tag such as @c{}, then the text will be sized to
    ## some nonzero default width and height. This helps in debugging
    ## applications, (especially in the case of text views which are
    ## initialized from datapaths) because zero width text fields
    ## would be invisible no matter what their text value was set to
    ## at runtime.
    ## 
    ## Text can be scrolled horizontally and vertically.
    ## 
    ## The API calls are @c{text.setYScroll(n)} and @c{text.setXcroll(n)},
    ## where @c{n <= 0}.
    ## 
    ## This scrolls the text vertically or horizontally by n pixels.
    ## 
    ## Note: If you want to scroll by lines rather than pixels,
    ## multiply by the font height of the text field. This won't
    ## really work for HTML formatted text which has multiple font
    ## size, but it will work for text with a single sized font.
    ## 
    ## If you want to know the total height of the text in a text
    ## field (if you want to know how large to draw a scrollbar, for
    ## example) there are a couple of ways to figure this out: For a
    ## multiline=false text field (i.e., one in which wrapping is not
    ## being done automatically by the system), you must manually
    ## count the number of linebreaks in the text, and then multiply
    ## by the font height.
    ## 
    ## For a multiline=true output text field, the system will compute
    ## a property text.scrollHeight which which you may examine. This
    ## field is not maintained for input text.
    element text {
      viewContent
      & textAttributes
      & (attribute text { xsd:string }
         | htmlText*)
    }
  | 
    ## An editable text field.  See the documentation for the @e{text}
    ## tag for a description of the @a{width} and @a{height} attributes,
    ## and of scrolling.
    element inputtext {
      viewContent
      & textAttributes
      & attribute resizable { boolean }?
      & 
        ## If true, the input text field acts like a password input
        ## field; any text typed in appears as "****" characters in the
        ## current font.
        [ a:defaultValue = "false" ] attribute password { boolean }?
      & (attribute text { xsd:string }
         | text?)
    }
textAttributes =
  
  ## If true, the lines of text are wrapped to fit within the text
  ## width.  (The name @c{multiline} is a misnomer.  Unwrapped text
  ## can be multiple lines if it contains a @c{
} or @c{

} ## element, or a line break within a @c{

} element.
  ## 
  ## This attribute defaults to true if width and height are
  ## explicitly specified.
  ## 
  ## If you set multiline=true, you probably want to explicitly a
  ## width for the text also; if multiline=true and you do not specify
  ## a width, the system will pick an arbitrary width (100 pixels at
  ## the moment).
  ## 
  ## When multiline=true, the text is automatially re-wrapped whenever
  ## the content is modified by calls to @c{setText()}, or whenever the
  ## width of the text view is modified.
  [ a:defaultValue = "false" lza:modifiers = "final" ]
  attribute multiline { boolean }?
  & 
    ## If true, the width of the text field will be recomputed each time
    ## setText() is called, so that the text view is exactly as wide as
    ## the width of the widest line.
    [ a:defaultValue = "false" ] attribute resize { booleanLiteral }?
  & 
    ## If true, the text is selectable
    [ a:defaultValue = "false" ]
    attribute selectable { booleanLiteral }?
  & attribute label { string }?
textContent =
  attribute text { xsd:string }
  | text?
htmlContent =
  attribute text { xsd:string }
  | htmlText?
htmlText =
  (text
   | 
     ## An HTML preformatted text region.  Whitespace and line breaks within
     ## this element are preserved.  This can only occur inside HTML text.
     element pre { htmlText }
   | 
     ## An HTML hypertext link.  This can only occur inside HTML text.
     element a {
       
       ## The link target.
       attribute href { xsd:anyURI }
       & 
         ## The value of this attribute determines where the link target
         ## will be displayed.  The interpretation is the same as in HTML,
         ## where the "current frame" is the frame containing the LZX
         ## application.  The value must be a name beginning with an
         ## alphabetic character, or one of the following:
         ## 
         ## 
##
@c{_blank}
##
## The user agent should load the designated ## document in a new, unnamed window. ##
##
@c{_parent}
##
## The user agent should load the document into ## the full, original window (thus canceling all other ## frames). This value is equivalent to @c{_self} if the current ## frame has no parent. ##
##
@c{_self}
##
## The user agent should load the document in ## the same frame as the element that refers to this target. ##
##
@c{_top}
##
## The user agent should load the document into ## the immediate FRAMESET parent of the current frame. This ## value is equivalent to @c{_self} if the current frame has no ## parent. ##
##
attribute target { "_blank" | "_parent" | "_self" | "_top" | xsd:string { pattern = "[a-zA-Z][a-zA-Z0-9\-_:.]*" } }? & htmlText } | ## HTML bold character markup. This can only occur inside HTML text. element b { htmlText } | ## A font element within HTML text specifies the font face, size, ## and color for text within this element. [ lza:name = "HTML font" ] element font { attribute face { string }? & attribute size { sizeLiteral }? & attribute color { colorLiteral }? & htmlText } | ## Italic character markup. This can only occur inside HTML text. element i { htmlText } | ## An HTML paragraph. This can only occur inside HTML text. element p { htmlText } | ## An HTML hard line break. This can only occur inside HTML text. element br { empty } | ## HTML underline character markup. This can only occur inside HTML text. element u { htmlText })* # # Assets # asset = ## Defines an audio object, that is compiled into the application. ## An audio source defined via @c{