XML literal
Syntax
-
XMLLiteral :
-
XMLMarkup
XMLElement
< > XMLElementContent </ >
-
XMLElement :
-
< XMLTagContent XMLWhitespaceopt />
< XMLTagContent XMLWhitespaceopt > XMLElementContent </ XMLTagName XMLWhitespaceopt >
-
XMLTagContent :
-
XMLTagName XMLAttributes
-
XMLTagName :
-
{ AssignmentExpressionallowIn }
XMLName
-
XMLAttributes :
-
XMLWhitespace { AssignmentExpressionallowIn }
XMLAttribute XMLAttributes
«empty»
-
XMLAttribute :
-
XMLWhitespace XMLName [lookahead ≠ XMLWhitespaceopt = ] [lookahead ≠ XMLWhitespaceopt &= ]
XMLWhitespace XMLName XMLWhitespaceopt = XMLWhitespaceopt { AssignmentExpressionallowIn }
XMLWhitespace XMLName XMLWhitespaceopt &= XMLWhitespaceopt Block
XMLWhitespace XMLName XMLWhitespaceopt = XMLWhitespaceopt XMLAttributeValue
-
XMLElementContent :
-
{ AssignmentExpressionallowIn } XMLElementContent
XMLMarkup XMLElementContent
XMLText XMLElementContent
XMLElement XMLElementContent
«empty»
Semantics
Unlike the E4X standard, ShockScript always trims any whitespace at the beginning and end of text nodes within XML literals regardless of the XMLContext object.
CDATA is indentation-aware similar to triple strings.
Note: If whitespace is desired on text nodes, one may use a CDATA section.
One reason for always trimming whitespace is that the source text may be autoformatted without breaking certain rules; although, CDATA sections may be trickier to format due to indentation, thus requiring type checking for determining whether the compiler understands such a section as an actual computer language such as a style block.
For general CDATA, an autoformatter will retain indentation starting from the lowest indent level.