Dev:attributeSyntax: Difference between revisions
[checked revision] | [checked revision] |
(-interwiki) |
(railML→{{rml}}) |
||
Line 19: | Line 19: | ||
== Character references == | == Character references == | ||
A | A {{rml}} file may contain character references such as every other XML file, e.g. '''ü''' or '''ü''' for the '''ü''' character. | ||
; {{external|https://www.w3.org/TR/REC-xml/#dt-charref|W3C Definition Character Reference}}: | ; {{external|https://www.w3.org/TR/REC-xml/#dt-charref|W3C Definition Character Reference}}: | ||
Line 29: | Line 29: | ||
</blockquote> | </blockquote> | ||
That means, character references may occur everywhere independent of the '''encoding''' declaration on top of the XML file. For the attribute-styled | That means, character references may occur everywhere independent of the '''encoding''' declaration on top of the XML file. For the attribute-styled {{rml}} files, they mainly may occur in attributes. Please be aware of this topic by consuming {{rml}} files. For further infos, you may start at the following {{external|https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references|Wikipedia site}}. | ||
[[Category:GeneralDescription]] | [[Category:GeneralDescription]] | ||
[[category:Common Concept]] | [[category:Common Concept]] |
Revision as of 17:42, 22 January 2024
XML Syntax issues
Correct quoting of XML attribute values
Sometimes there is a little confusion about the correct XML syntax in attribute definitions. Which version is valid, which not?
- <element attribute="value"/>
- <element attribute='value'/>
The W3C XML specification gives us the answer: both are correct!
Usage in XML parsers and XML processors
Thus each XML parser has to accept both versions (according to the W3C standard), and you may choose to use either one in your output.
From current experience, it has to be noted that XML files with "double quotes" as attribute delimiters are much more common than XML file with 'single quotes'.
Character references
A railML® file may contain character references such as every other XML file, e.g. ü or ü for the ü character.
A character reference refers to a specific character in the ISO/IEC 10646 character set, for example one not directly accessible from available input devices.
[66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'
...
If the character reference begins with " &#x ", the digits and letters up to the terminating ; provide a hexadecimal representation of the character's code point in ISO/IEC 10646. If it begins just with " &# ", the digits up to the terminating ; provide a decimal representation of the character's code point.
That means, character references may occur everywhere independent of the encoding declaration on top of the XML file. For the attribute-styled railML® files, they mainly may occur in attributes. Please be aware of this topic by consuming railML® files. For further infos, you may start at the following Wikipedia site (external link).