RE: usage of entities (for dummies)
Adding to DC's response: > 2.) What is the difference of the usage of - for example - > "&" and "&"? When do i have to use the one and not the other? The first is technically an "entity reference", the second is a "character reference". The only difference is that entities have to be declared in the DTD, except for the five built-in ones. Numeric character references can be used without needing a declaration. > 3.) And where can i find a good overview of enitites? I use Bob duCharme's "Annotated XML Specification" - very useful because it gives the actual text of the specification, then Bob's explanation of what it really means. > > Finally i have also a non-entity question: > I have to replace many of equivalent placeholders in the same > text too. Do i have to nest replace-functions for each of > them in one another like ... > <xsl:value-of select="replace(replace(., '\^12', 'ç'), > '\^13', '&')"/> ... or is there a more elegant solution for this? > As well as DC's solution, another approach is to have a table of replacements: <xsl:variable name="mods" as="element(mod)*"> <mod from="\^12" to="ç"/> <mod from="\^13" to="&"/> </xsl:variable> and run through them with a recursive function: <xsl:function name="f:multi-replace" as="xs:string"> <xsl:param name="in" as="xs:string"/> <xsl:param name="mods" as="element(mod)*"/> <xsl:choose> <xsl:when test="$mods"> <xsl:sequence select="f:multi-replace( replace($in, $mods/@from, $mods/@to), subsequence($mods, 2))"/> </xsl:when> <xsl:otherwise> <xsl:sequence select="$in"/> </xsl:otherwise> </ </ Michael Kay http://www.saxonica.com/
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format