How do I alter the DITA menucascade separator for a custom element?>
Description
We have added two custom elements to our DITA DTDS, privcascade, based on menucascade, and privilege, based on uicontrol. We want the privcascades to have a period as a separator, whereas menucascade uses the > separator.
I added text to character.xsl to process the privcascades, but they keep coming out with whatever separator is specified for menucascade. I can change the separator for menucascade in the character.xsl file, so I think this is the file that controls this behavior.
Any ideas how to get WebWorks to apply a different separator for privcascades?
Contents
Details
The class attributes are as follows:
+ topic/ph ui-d/uicontrol vm-d/privilege + topic/ph ui-d/menucascade vm-d/privcascade
The text from character.xls is:
1 <xsl:template match="*[contains(@class, ' vm-d/privilege ')]" mode="wwmode:character-prefix"> 2 <xsl:param name="ParamNode" select="." /> 3 4 <xsl:if test="($ParamNode/parent::*[contains(@class,' vm-d/privcascade ')]) and ($ParamNode/preceding-sibling::*[contains(@class, ' vm-d/privilege ')])"> 5 <xsl:variable name="VarBaseID"> 6 <xsl:call-template name="Generate-ID"> 7 <xsl:with-param name="ParamNode" select="$ParamNode" /> 8 </xsl:call-template> 9 </xsl:variable> 10 11 <!-- Use period as separator for privcascades --> 12 <wwdoc:TextRun id="{$VarBaseID}sep"> 13 <wwdoc:Text value="." /> 14 </wwdoc:TextRun> 15 </xsl:if> 16 </xsl:template> 17 18 19 <xsl:template match="*[contains(@class, ' ui-d/uicontrol ')]" mode="wwmode:character-prefix"> 20 <xsl:param name="ParamNode" select="." /> 21 22 <xsl:if test="($ParamNode/parent::*[contains(@class,' ui-d/menucascade ')]) and ($ParamNode/preceding-sibling::*[contains(@class, ' ui-d/uicontrol ')])"> 23 <xsl:variable name="VarBaseID"> 24 <xsl:call-template name="Generate-ID"> 25 <xsl:with-param name="ParamNode" select="$ParamNode" /> 26 </xsl:call-template> 27 </xsl:variable> 28 29 <wwdoc:TextRun id="{$VarBaseID}sep"> 30 <wwdoc:Text value=" > " /> 31 </wwdoc:TextRun> 32 </xsl:if> 33 </xsl:template>
Response
Reviewing the class attributes:
+ topic/ph ui-d/uicontrol vm-d/privilege + topic/ph ui-d/menucascade vm-d/privcascade
and the XSL code:
1 <xsl:template match="*[contains(@class, ' vm-d/privilege ')]" 2 mode="wwmode:character-prefix"> 3 <xsl:param name="ParamNode" select="." /> 4 5 <xsl:if test="($ParamNode/parent::*[contains(@class,' vm-d/privcascade ')]) and ($ParamNode/preceding-sibling::*[contains(@class, ' vm-d/privilege ')])"> 6 ... 7 8 <xsl:template match="*[contains(@class, ' ui-d/uicontrol ')]" 9 mode="wwmode:character-prefix"> 10 <xsl:param name="ParamNode" select="." /> 11 12 <xsl:if test="($ParamNode/parent::*[contains(@class,' ui-d/menucascade ')]) and ($ParamNode/preceding-sibling::*[contains(@class, ' ui-d/uicontrol ')])"> 13 ...
It looks like you maybe wanted to combine these two templates into a single match against ' ui-d/uicontrol '.
1 <xsl:template match="*[contains(@class, ' ui-d/uicontrol ')]" mode="wwmode:character-prefix"> 2 <xsl:param name="ParamNode" select="." /> 3 4 <xsl:choose> 5 <xsl:when test="($ParamNode/parent::*[contains(@class,' ui-d/menucascade ')]) and ($ParamNode/preceding-sibling::*[contains(@class, ' ui-d/uicontrol ')])"> 6 <xsl:variable name="VarBaseID"> 7 <xsl:call-template name="Generate-ID"> 8 <xsl:with-param name="ParamNode" select="$ParamNode" /> 9 </xsl:call-template> 10 </xsl:variable> 11 12 <wwdoc:TextRun id="{$VarBaseID}sep"> 13 <wwdoc:Text value=" > " /> 14 </wwdoc:TextRun> 15 </xsl:when> 16 17 <xsl:when test="($ParamNode/parent::*[contains(@class,' vm-d/privcascade ')]) and ($ParamNode/preceding-sibling::*[contains(@class, ' vm-d/privilege ')])"> 18 <xsl:variable name="VarBaseID"> 19 <xsl:call-template name="Generate-ID"> 20 <xsl:with-param name="ParamNode" select="$ParamNode" /> 21 </xsl:call-template> 22 </xsl:variable> 23 24 <!-- Use period as separator for privcascades --> 25 <wwdoc:TextRun id="{$VarBaseID}sep"> 26 <wwdoc:Text value="." /> 27 </wwdoc:TextRun> 28 </xsl:when> 29 </xsl:choose> 30 </xsl:template>
This is going to be very sensitive to your input DITA document structure. Can you provide an example source snippet?
Example XML
Example XML from Teresa:
1 <?xml version="1.0" encoding="UTF-16"?> 2 <!DOCTYPE task PUBLIC "-//VMWARE//DTD DITA Task//EN" "vmbase.dtd"> 3 <task id="task_234B9121E3464C929CAEDFD9726B9B37"> 4 <title>Privilege</title> 5 <shortdesc id="shortdesc_FB3D51318F964BA184C22869FCB9BCDE"> 6 This topic tests the appearance of the privilege element, a VMware DTD addition. My single priv: <privilege>My single priv</privilege>. My priv cascade: <privcascade> 7 <privilege>FirstPriv</privilege> 8 <privilege>secondpriv</privilege> 9 <privilege>thirdpriv</privilege> 10 <privilege>fourthpriv</privilege> 11 <privilege>fifthPriv</privilege> 12 <privilege>6thpriv</privilege> 13 <privilege>7th priv</privilege> 14 <privilege>8th priv</privilege> 15 <privilege>9th priv</privilege> 16 <privilege>10th and final priv</privilege> 17 </privcascade> 18 </shortdesc> 19 <taskbody> 20 <prereq id="prereq_ED0EC891FE304EE58B3283B39AC320D3"> 21 <p id="p_1B504D7E562546ED9D4D0DC4577BD8A1"> 22 My single priv: <privilege>My single priv</privilege>. My priv cascade: <privcascade> 23 <privilege>FirstPriv</privilege> 24 <privilege>secondpriv</privilege> 25 <privilege>thirdpriv</privilege> 26 <privilege>fourthpriv</privilege> 27 <privilege>fifthPriv</privilege> 28 <privilege>6thpriv</privilege> 29 <privilege>7th priv</privilege> 30 <privilege>8th priv</privilege> 31 <privilege>9th priv</privilege> 32 <privilege>10th and final priv</privilege> 33 </privcascade> 34 </p> 35 <p id="p_790BC7B7BB254E538B19E00C867F8411">My prereq. </p> 36 </prereq> 37 <context id="context_38DBFDF82EC04DDE911AE836ECC8F6D4"> 38 <p id="p_986B8242D41341E7810788F609325162"> 39 My context. Privs in context. My single priv: <privilege>My single priv</privilege>. My priv cascade: <privcascade> 40 <privilege>FirstPriv</privilege> 41 <privilege>secondpriv</privilege> 42 <privilege>thirdpriv</privilege> 43 <privilege>fourthpriv</privilege> 44 <privilege>fifthPriv</privilege> 45 <privilege>6thpriv</privilege> 46 <privilege>7th priv</privilege> 47 <privilege>8th priv</privilege> 48 <privilege>9th priv</privilege> 49 <privilege>10th and final priv</privilege> 50 </privcascade> 51 </p> 52 </context> 53 <steps id="steps_11F2401887CC4056BEF34AA72B0458BF"> 54 <step id="step_E9F5D1F79D6240EB9DE7F27343B8E300"> 55 <cmd> 56 My step. Privs in step My single priv: <privilege>My single priv</privilege>. My priv cascade: <privcascade> 57 <privilege>FirstPriv</privilege> 58 <privilege>secondpriv</privilege> 59 <privilege>thirdpriv</privilege> 60 <privilege>fourthpriv</privilege> 61 <privilege>fifthPriv</privilege> 62 <privilege>6thpriv</privilege> 63 <privilege>7th priv</privilege> 64 <privilege>8th priv</privilege> 65 <privilege>9th priv</privilege> 66 <privilege>10th and final priv</privilege> 67 </privcascade> 68 </cmd> 69 <substeps id="substeps_C4C5226146C04CBDA38C7CAE8267AC7A"> 70 <substep id="substep_971B6A0FCA6E4A95866FF8A18C1A982A"> 71 <cmd> 72 My substep. Privs in substep. My single priv: <privilege>My single priv</privilege>. My priv cascade: <privcascade> 73 <privilege>FirstPriv</privilege> 74 <privilege>secondpriv</privilege> 75 <privilege>thirdpriv</privilege> 76 <privilege>fourthpriv</privilege> 77 <privilege>fifthPriv</privilege> 78 <privilege>6thpriv</privilege> 79 <privilege>7th priv</privilege> 80 <privilege>8th priv</privilege> 81 <privilege>9th priv</privilege> 82 <privilege>10th and final priv</privilege> 83 </privcascade> 84 </cmd> 85 <info> 86 substep info. My single priv: <privilege>My single priv</privilege>. My priv cascade: <privcascade> 87 <privilege>FirstPriv</privilege> 88 <privilege>secondpriv</privilege> 89 <privilege>thirdpriv</privilege> 90 <privilege>fourthpriv</privilege> 91 <privilege>fifthPriv</privilege> 92 <privilege>6thpriv</privilege> 93 <privilege>7th priv</privilege> 94 <privilege>8th priv</privilege> 95 <privilege>9th priv</privilege> 96 <privilege>10th and final priv</privilege> 97 </privcascade> 98 </info> 99 <stepresult> 100 substep result. My single priv: <privilege>My single priv</privilege>. My priv cascade: <privcascade> 101 <privilege>FirstPriv</privilege> 102 <privilege>secondpriv</privilege> 103 <privilege>thirdpriv</privilege> 104 <privilege>fourthpriv</privilege> 105 <privilege>fifthPriv</privilege> 106 <privilege>6thpriv</privilege> 107 <privilege>7th priv</privilege> 108 <privilege>8th priv</privilege> 109 <privilege>9th priv</privilege> 110 <privilege>10th and final priv</privilege> 111 </privcascade> 112 </stepresult> 113 </substep> 114 </substeps> 115 <info> 116 step info. My single priv: <privilege>My single priv</privilege>. My priv cascade: <privcascade> 117 <privilege>FirstPriv</privilege> 118 <privilege>secondpriv</privilege> 119 <privilege>thirdpriv</privilege> 120 <privilege>fourthpriv</privilege> 121 <privilege>fifthPriv</privilege> 122 <privilege>6thpriv</privilege> 123 <privilege>7th priv</privilege> 124 <privilege>8th priv</privilege> 125 <privilege>9th priv</privilege> 126 <privilege>10th and final priv</privilege> 127 </privcascade> 128 </info> 129 <stepxmp> 130 step example. My single priv: <privilege>My single priv</privilege>. My priv cascade: <privcascade> 131 <privilege>FirstPriv</privilege> 132 <privilege>secondpriv</privilege> 133 <privilege>thirdpriv</privilege> 134 <privilege>fourthpriv</privilege> 135 <privilege>fifthPriv</privilege> 136 <privilege>6thpriv</privilege> 137 <privilege>7th priv</privilege> 138 <privilege>8th priv</privilege> 139 <privilege>9th priv</privilege> 140 <privilege>10th and final priv</privilege> 141 </privcascade> 142 </stepxmp> 143 <stepresult> 144 Step result. Privs in step result. My single priv: <privilege>My single priv</privilege>. My priv cascade: <privcascade> 145 <privilege>FirstPriv</privilege> 146 <privilege>secondpriv</privilege> 147 <privilege>thirdpriv</privilege> 148 <privilege>fourthpriv</privilege> 149 <privilege>fifthPriv</privilege> 150 <privilege>6thpriv</privilege> 151 <privilege>7th priv</privilege> 152 <privilege>8th priv</privilege> 153 <privilege>9th priv</privilege> 154 <privilege>10th and final priv</privilege> 155 </privcascade> 156 </stepresult> 157 </step> 158 </steps> 159 <result id="result_EAF10472326D492293CD55D5E2262D17"> 160 <p id="p_EF24751196C743669A8048C49225042E"> 161 My task result. My single priv: <privilege>My single priv</privilege>. My priv cascade: <privcascade> 162 <privilege>FirstPriv</privilege> 163 <privilege>secondpriv</privilege> 164 <privilege>thirdpriv</privilege> 165 <privilege>fourthpriv</privilege> 166 <privilege>fifthPriv</privilege> 167 <privilege>6thpriv</privilege> 168 <privilege>7th priv</privilege> 169 <privilege>8th priv</privilege> 170 <privilege>9th priv</privilege> 171 <privilege>10th and final priv</privilege> 172 </privcascade> 173 </p> 174 </result> 175 <example id="example_5855756EAA19495A9D89D5DEE2E5F95B"> 176 <title>My Example</title>Privs in example. My single priv: <privilege>My single priv</privilege>. My priv cascade: <privcascade> 177 <privilege>FirstPriv</privilege> 178 <privilege>secondpriv</privilege> 179 <privilege>thirdpriv</privilege> 180 <privilege>fourthpriv</privilege> 181 <privilege>fifthPriv</privilege> 182 <privilege>6thpriv</privilege> 183 <privilege>7th priv</privilege> 184 <privilege>8th priv</privilege> 185 <privilege>9th priv</privilege> 186 <privilege>10th and final priv</privilege> 187 </privcascade> 188 </example> 189 <postreq id="postreq_98718917D2D9420A84900FD40BE496E1"> 190 <p id="p_B10564619848475C9A0C6DCCA7F3A56C"> 191 My post req. My single priv: <privilege>My single priv</privilege>. My priv cascade: <privcascade> 192 <privilege>FirstPriv</privilege> 193 <privilege>secondpriv</privilege> 194 <privilege>thirdpriv</privilege> 195 <privilege>fourthpriv</privilege> 196 <privilege>fifthPriv</privilege> 197 <privilege>6thpriv</privilege> 198 <privilege>7th priv</privilege> 199 <privilege>8th priv</privilege> 200 <privilege>9th priv</privilege> 201 <privilege>10th and final priv</privilege> 202 </privcascade> 203 </p> 204 </postreq> 205 </taskbody> 206 </task>
Simplified Example XML
Here's the smallest possible example of what we're trying to match against:
1 <p id="p_1B504D7E562546ED9D4D0DC4577BD8A1"> 2 My single priv: <privilege>My single priv</privilege>. My priv cascade: <privcascade> 3 <privilege>FirstPriv</privilege> 4 <privilege>secondpriv</privilege> 5 <privilege>thirdpriv</privilege> 6 <privilege>fourthpriv</privilege> 7 <privilege>fifthPriv</privilege> 8 <privilege>6thpriv</privilege> 9 <privilege>7th priv</privilege> 10 <privilege>8th priv</privilege> 11 <privilege>9th priv</privilege> 12 <privilege>10th and final priv</privilege> 13 </privcascade> 14 </p>
Okay, so reviewing the class definition:
+ topic/ph ui-d/uicontrol vm-d/privilege
and the match expressions:
<xsl:template match="*[contains(@class, ' vm-d/privilege ')]" mode="wwmode:character-prefix"> ... <xsl:template match="*[contains(@class, ' ui-d/uicontrol ')]" mode="wwmode:character-prefix"> ...
This is occurring because XSL is giving priority to the last match with the same priority. In this case, these two match expressions have the same "complexity", so they receive the same match priority. From there, the last match wins.
So, you can either move your ' vm-d/privilege ' match after your ' ui-d/uicontrol ' match or set explicit priority attributes on the match templates.
Aside
This problem can also be solved/addressed in the default.wwconfig by using similar match expressions and emitting <wwdoc:Number> segments for these different class types.