Subject: RE: [xsl] usage of entities (for dummies) From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Thu, 3 Aug 2006 11:26:32 +0100 |
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[1]/@from, $mods[1]/@to), subsequence($mods, 2))"/> </xsl:when> <xsl:otherwise> <xsl:sequence select="$in"/> </xsl:otherwise> </ </ Michael Kay http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] usage of entities (for du, David Carlisle | Thread | Re: [xsl] usage of entities (for du, Georg Hohmann |
RE: [xsl] Global parameters with UT, Michael Kay | Date | Re: [xsl] usage of entities (for du, Georg Hohmann |
Month |