|
xstring Glossary System
Detailed Description
xstring GrammarThe xstring grammar is based on the XML 1.1 grammar specification (http://www.w3.org/TR/2004/REC-xml11-20040204/) S = (#x20 | #x09 | #x0D | #x0A)+
Char = [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
CharData = [^<&]*
CharRef = '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'
NameStartChar = ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] |
[#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] |
[#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
[#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] |
[#x10000-#xEFFFF]
NameChar = NameStartChar | "-" | "." | [0-9] | #xB7 |
[#x0300-#x036F] | [#x203F-#x2040]
Name = NameStartChar (NameChar)*
EntityRef = '&' Name ';'
Reference = EntityRef | CharRef
AttValue = '"' ([^<&"] | Reference)* '"' |
"'" ([^<&'] | Reference)* "'"
Eq = S? '=' S?
Attribute = Name Eq AttValue
EmptyElemTag = '<' Name (S Attribute)* S? '/>'
STag = '<' Name (S Attribute)* S? '>'
ETag = '</' Name S? '>'
content = CharData? ((element | Reference | Comment) CharData?)*
element = EmptyElemTag | STag content ETag
translation_unit = element*
ContextOverviewThe context of a string is a runtime evaluated collection of information about the state of the machine and the xstring that we currently care about. This context is gathered from several locations: -# the runtime context of the xstring system (which includes some defaults) -# the static attributes of the xstring definition The runtime context of the xstring system can be manipulated with the adobe::xstring_context_t class. The runtime context has several pieces of information set by default. These pieces are:
The static attributes of the xstring definition also provide context. Example: <xstr id='hello_world' lang='es-sp'>Hola, mundo!</xstr> In the above example the two bits of context are 'id' and 'lang'. These override specific context information as outlined in the "Context Merging" section. MergingThere are several context merges that take place in the use of the xstring system. Context merges are necessary because there are several places from which the context of a string is gathered, and conflicting pieces of context must be resolved before the string can be imported into or looked up in the xstring glossary. This section describes the rules by which parts of one source context overrides another to obtain the final context for an xstring. Merging During Importing Into the GlossaryWhen importing into the glossary the only context taken into account is the static context defined in the xstring. Merging During LookupWhen looking up an xstring in the glossary, first the xstring is parsed to obtain its static context. The runtime context defined by adobe::xstring_context_t is then merged with the static context, and the static context value takes precedence in the case of a conflict. LookupDuring lookup, the source xstring context is completely resolved first. Then the source xstring is compared to the xstrings in the glossary that have the same Marker ReplacementIt is possible for the xstring system to handle marker replacement inside xstrings. A marker is simply an xml tag in an xstring to be removed later and replaced with another string (which itself can be the product of a previous xstring lookup). An example might be: <xstr id='greeting'>Hello, <marker id='user_name'/></xstr> During xstring marker replacement the engine will extract all the xstrings in the glossary with the same ExampleGiven the following in the xstring glossary: <xstr id='replacement_test_1'>I think <marker id='good_thing'/> is a Good Thing</xstr> <xstr id='replacement_test_1'>I think <marker id='bad_thing'/> is a Bad Thing</xstr> <xstr id='replacement_test_1'>I don't think anything about <marker id='whatever'/></xstr> <xstr id="a_good_thing"><marker id="good_thing">ice cream</marker></xstr> <xstr id="a_bad_thing"><marker id="bad_thing">the Taliban</marker></xstr> <xstr id="a_neutral_thing"><marker id="whatever">yellow traffic lights</marker></xstr> And given the following code: std::string good_thing(adobe::xstring("<xstr id='a_good_thing'/>")); std::string bad_thing(adobe::xstring("<xstr id='a_bad_thing'/>")); std::string neutral_thing(adobe::xstring("<xstr id='a_neutral_thing'/>")); std::cout << "good marker: " << good_thing << std::endl; std::cout << "bad marker: " << bad_thing << std::endl; std::cout << "neutral marker: " << neutral_thing << std::endl; std::cout << "Good: " << adobe::xstring_replace(adobe::static_name_t("replacement_test_1"), good_thing) << std::endl; std::cout << "Bad: " << adobe::xstring_replace(adobe::static_name_t("replacement_test_1"), bad_thing) << std::endl; std::cout << "Neutral: " << adobe::xstring_replace(adobe::static_name_t("replacement_test_1"), neutral_thing) << std::endl; We get the following output: good marker: <marker id='good_thing'>ice cream</marker> bad marker: <marker id='bad_thing'>the Taliban</marker> neutral marker: <marker id='whatever'>yellow traffic lights</marker> Good: I think ice cream is a Good Thing Bad: I think the Taliban is a Bad Thing Neutral: I don't think anything about yellow traffic lights Note first of all that we extracted our markers from the xstring glossary itself before we used them for marker replacement. This gives you the ability to localize your markers before you use them in marker replacement. Note also that there are three xstrings with the Marker Replacement NotesWithin a single marker replacement pass, it is illegal to have one marker directly nested within another marker, either in the source xstring or as a replacement marker, e.g.: <marker id="foo"><marker id="bar"/></marker> Other XML tags, however, are allowed. Typedef Documentation
Callback for the XML fragment parser. When the fragment parser finds a well formed element, it will signal a function with this signature with the following parameters:
Definition at line 436 of file xml_parser.hpp. Function Documentation
Parses a fragment of XML, outputting the result to an OutputIterator instance.
Definition at line 205 of file xstring.hpp.
Parses a fragment of XML, outputting the result to an OutputIterator instance.
Definition at line 220 of file xstring.hpp.
Parses a fragment of XML, outputting the result to an OutputIterator instance.
Definition at line 224 of file xstring.hpp.
Definition at line 232 of file xstring.hpp.
Definition at line 236 of file xstring.hpp.
Definition at line 243 of file xstring.hpp.
Definition at line 252 of file xstring.hpp.
Clears the entire contents of the xstring glossary
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

