Attachment 'nameinfo_modified.xsl'

Download

   1 <?xml version="1.0" encoding="UTF-8"?>
   2 <xsl:stylesheet version="1.0" xmlns="urn:WebWorks-Engine-Splits-Schema"
   3                               xmlns:wwsplits="urn:WebWorks-Engine-Splits-Schema"
   4                               xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   5                               xmlns:msxsl="urn:schemas-microsoft-com:xslt"
   6                               xmlns:wwmode="urn:WebWorks-Engine-Mode"
   7                               xmlns:wwfiles="urn:WebWorks-Engine-Files-Schema"
   8                               xmlns:wwdoc="urn:WebWorks-Document-Schema"
   9                               xmlns:wwbehaviors="urn:WebWorks-Behaviors-Schema"
  10                               xmlns:wwproject="urn:WebWorks-Publish-Project"
  11                               xmlns:wwprogress="urn:WebWorks-XSLT-Extension-Progress"
  12                               xmlns:wwlog="urn:WebWorks-XSLT-Extension-Log"
  13                               xmlns:wwfilesystem="urn:WebWorks-XSLT-Extension-FileSystem"
  14                               xmlns:wwuri="urn:WebWorks-XSLT-Extension-URI"
  15                               xmlns:wwstring="urn:WebWorks-XSLT-Extension-StringUtilities"
  16                               xmlns:wwfilesext="urn:WebWorks-XSLT-Extension-Files"
  17                               xmlns:wwprojext="urn:WebWorks-XSLT-Extension-Project"
  18                               xmlns:wwexsldoc="urn:WebWorks-XSLT-Extension-Document"
  19                               exclude-result-prefixes="xsl msxsl wwsplits wwmode wwfiles wwdoc wwbehaviors wwproject wwprogress wwlog wwfilesystem wwuri wwstring wwfilesext wwprojext wwexsldoc"
  20 >
  21  <xsl:param name="GlobalInput" />
  22  <xsl:param name="GlobalPipelineName" />
  23  <xsl:param name="GlobalProject" />
  24  <xsl:param name="GlobalFiles" />
  25  <xsl:param name="ParameterDocumentType" />
  26  <xsl:param name="ParameterDependsType" />
  27  <xsl:param name="ParameterBehaviorsType" />
  28  <xsl:param name="ParameterType" />
  29  <xsl:param name="ParameterEmitTableEntries" select="'false'" />
  30 
  31 
  32  <xsl:namespace-alias stylesheet-prefix="wwsplits" result-prefix="#default" />
  33  <xsl:strip-space elements="*" />
  34 
  35 
  36  <xsl:key name="wwfiles-files-by-documentid" match="wwfiles:File" use="@documentID" />
  37  <xsl:key name="wwbehaviors-splits-by-id" match="wwbehaviors:Split" use="@id" />
  38  <xsl:key name="wwbehaviors-markers-by-id" match="wwbehaviors:Marker" use="@id" />
  39 
  40 
  41  <xsl:variable name="GlobalActionChecksum">
  42   <xsl:variable name="VarTransformChecksums">
  43    <xsl:value-of select="concat(wwuri:AsFilePath('wwtransform:self'), ':', wwfilesystem:GetChecksum(wwuri:AsFilePath('wwtransform:self')))" />
  44   </xsl:variable>
  45   <xsl:value-of select="wwstring:MD5Checksum($VarTransformChecksums)" />
  46  </xsl:variable>
  47 
  48 
  49  <xsl:template match="/">
  50   <wwfiles:Files version="1.0">
  51 
  52    <!-- Groups -->
  53    <!--        -->
  54    <xsl:variable name="VarProjectGroups" select="$GlobalProject/wwproject:Project/wwproject:Groups/wwproject:Group" />
  55    <xsl:variable name="VarProgressProjectGroupsStart" select="wwprogress:Start(count($VarProjectGroups))" />
  56    <xsl:for-each select="$VarProjectGroups">
  57     <xsl:variable name="VarProjectGroup" select="." />
  58     <xsl:variable name="VarProjectGroupPosition" select="position()" />
  59 
  60     <xsl:variable name="VarProgressProjectGroupStart" select="wwprogress:Start(1)" />
  61 
  62     <!-- Aborted? -->
  63     <!--          -->
  64     <xsl:if test="not(wwprogress:Abort())">
  65      <!-- Documents -->
  66      <!--           -->
  67      <xsl:variable name="VarProjectDocuments" select="$VarProjectGroup//wwproject:Document" />
  68      <xsl:variable name="VarProgressProjectDocumentsStart" select="wwprogress:Start(count($VarProjectDocuments))" />
  69      <xsl:for-each select="$VarProjectDocuments">
  70       <xsl:variable name="VarProjectDocument" select="." />
  71       <xsl:variable name="VarProjectDocumentPosition" select="position()" />
  72 
  73       <xsl:variable name="VarProgressProjectDocumentStart" select="wwprogress:Start(1)" />
  74 
  75       <!-- Aborted? -->
  76       <!--          -->
  77       <xsl:if test="not(wwprogress:Abort())">
  78        <!-- Splits -->
  79        <!--        -->
  80        <xsl:for-each select="$GlobalFiles[1]">
  81         <xsl:variable name="VarFilesWithDocumentID" select="key('wwfiles-files-by-documentid', $VarProjectDocument/@DocumentID)" />
  82 
  83         <!-- Load splits -->
  84         <!--             -->
  85         <xsl:variable name="VarFilesSplits" select="$VarFilesWithDocumentID[@type = $ParameterDependsType][1]" />
  86         <xsl:variable name="VarSplits" select="wwexsldoc:LoadXMLWithoutResolver($VarFilesSplits/@path)" />
  87 
  88         <xsl:variable name="VarFilesDocument" select="$VarFilesWithDocumentID[@type = $ParameterDocumentType][1]" />
  89         <xsl:for-each select="$VarFilesDocument[1]">
  90          <xsl:variable name="VarFilesBehaviors" select="$VarFilesWithDocumentID[@type = $ParameterBehaviorsType][1]" />
  91          <xsl:for-each select="$VarFilesBehaviors[1]">
  92           <!-- Call template -->
  93           <!--               -->
  94           <xsl:variable name="VarPath" select="wwfilesystem:Combine(wwfilesystem:GetDirectoryName($VarFilesSplits/@path), concat(translate($ParameterType, ':', '_'),'.xml'))" />
  95           <xsl:variable name="VarUpToDate" select="wwfilesext:UpToDate($VarPath, '', $VarFilesSplits/@groupID, $VarFilesSplits/@documentID, $GlobalActionChecksum)" />
  96           <xsl:if test="not($VarUpToDate)">
  97            <xsl:variable name="VarResultAsXML">
  98             <!-- Load document -->
  99             <!--               -->
 100             <xsl:variable name="VarDocument" select="wwexsldoc:LoadXMLWithoutResolver($VarFilesDocument/@path)" />
 101             <xsl:variable name="VarBehaviors" select="wwexsldoc:LoadXMLWithoutResolver($VarFilesBehaviors/@path)" />
 102 
 103             <xsl:call-template name="NameInfo">
 104              <xsl:with-param name="ParamProjectGroup" select="$VarProjectGroup" />
 105              <xsl:with-param name="ParamProjectGroupPosition" select="$VarProjectGroupPosition" />
 106              <xsl:with-param name="ParamProjectDocument" select="$VarProjectDocument" />
 107              <xsl:with-param name="ParamProjectDocumentPosition" select="$VarProjectDocumentPosition" />
 108              <xsl:with-param name="ParamDocument" select="$VarDocument" />
 109              <xsl:with-param name="ParamBehaviors" select="$VarBehaviors" />
 110              <xsl:with-param name="ParamSplits" select="$VarSplits" />
 111             </xsl:call-template>
 112            </xsl:variable>
 113            <xsl:variable name="VarResult" select="msxsl:node-set($VarResultAsXML)" />
 114            <xsl:variable name="VarWriteResult" select="wwexsldoc:Document($VarResult, $VarPath, 'utf-8', 'xml', '1.0', 'yes')" />
 115           </xsl:if>
 116 
 117           <wwfiles:File path="{$VarPath}" type="{$ParameterType}" checksum="{wwfilesystem:GetChecksum($VarPath)}" projectchecksum="" groupID="{$VarFilesSplits/@groupID}" documentID="{$VarFilesSplits/@documentID}" actionchecksum="{$GlobalActionChecksum}">
 118            <wwfiles:Depends path="{$VarFilesDocument/@path}" checksum="{$VarFilesDocument/@checksum}" groupID="{$VarFilesDocument/@groupID}" documentID="{$VarFilesDocument/@documentID}" />
 119            <wwfiles:Depends path="{$VarFilesSplits/@path}" checksum="{$VarFilesSplits/@checksum}" groupID="{$VarFilesSplits/@groupID}" documentID="{$VarFilesSplits/@documentID}" />
 120            <wwfiles:Depends path="{$VarFilesBehaviors/@path}" checksum="{$VarFilesBehaviors/@checksum}" groupID="{$VarFilesBehaviors/@groupID}" documentID="{$VarFilesBehaviors/@documentID}" />
 121           </wwfiles:File>
 122          </xsl:for-each>
 123         </xsl:for-each>
 124        </xsl:for-each>
 125       </xsl:if>
 126 
 127       <xsl:variable name="VarProgressProjectDocumentEnd" select="wwprogress:End()" />
 128      </xsl:for-each>
 129 
 130      <xsl:variable name="VarProgressProjectDocumentsEnd" select="wwprogress:End()" />
 131     </xsl:if>
 132 
 133     <xsl:variable name="VarProgressProjectGroupEndt" select="wwprogress:End()" />
 134    </xsl:for-each>
 135 
 136    <xsl:variable name="VarProgressProjectGroupsEnd" select="wwprogress:End()" />
 137   </wwfiles:Files>
 138  </xsl:template>
 139 
 140 
 141  <xsl:template name="GetFileNameMarkers">
 142   <xsl:param name="ParamBehaviors" />
 143   <xsl:param name="ParamMarkers" />
 144 
 145   <!-- Create filename markers -->
 146   <!--                         -->
 147   <xsl:for-each select="$ParamMarkers">
 148    <xsl:variable name="VarMarker" select="." />
 149 
 150    <xsl:for-each select="$ParamBehaviors[1]">
 151     <xsl:variable name="VarBehaviorMarker" select="key('wwbehaviors-markers-by-id', $VarMarker/@id)" />
 152 
 153     <xsl:for-each select="$VarBehaviorMarker[1][(@behavior = 'filename') or (@behavior = 'filename-and-topic')]">
 154      <xsl:variable name="VarFileName">
 155       <xsl:for-each select="$VarMarker/wwdoc:TextRun/wwdoc:Text">
 156        <xsl:value-of select="@value" />
 157       </xsl:for-each>
 158      </xsl:variable>
 159      <xsl:variable name="VarNormalizedFileName" select="normalize-space($VarFileName)" />
 160 
 161      <xsl:if test="string-length($VarNormalizedFileName) &gt; 0">
 162       <wwsplits:FileName value="{$VarNormalizedFileName}" />
 163      </xsl:if>
 164     </xsl:for-each>
 165    </xsl:for-each>
 166   </xsl:for-each>
 167  </xsl:template>
 168 
 169 
 170  <xsl:template name="NameInfo">
 171   <xsl:param name="ParamProjectGroup" />
 172   <xsl:param name="ParamProjectGroupPosition" />
 173   <xsl:param name="ParamProjectDocument" />
 174   <xsl:param name="ParamProjectDocumentPosition" />
 175   <xsl:param name="ParamDocument" />
 176   <xsl:param name="ParamBehaviors" />
 177   <xsl:param name="ParamSplits" />
 178 
 179   <xsl:variable name="VarDocumentNameWithoutExtension" select="wwfilesystem:GetFileNameWithoutExtension(wwprojext:GetDocumentPath($ParamProjectDocument/@DocumentID))" />
 180 
 181   <wwsplits:Splits version="1.0">
 182    <xsl:for-each select="$ParamSplits/wwsplits:Splits/wwsplits:Split">
 183     <xsl:variable name="VarSplit" select="." />
 184     <xsl:variable name="VarPosition" select="position()" />
 185 
 186     <!-- Identify start/end positions -->
 187     <!--                              -->
 188     <xsl:variable name="VarStartPosition" select="@documentposition" />
 189     <xsl:variable name="VarEndPosition">
 190      <xsl:choose>
 191       <xsl:when test="position() = last()">
 192        <xsl:value-of select="count($ParamDocument/wwdoc:Document/wwdoc:Content/*)" />
 193       </xsl:when>
 194 
 195       <xsl:otherwise>
 196        <xsl:value-of select="following-sibling::wwsplits:Split[1]/@documentposition - 1" />
 197       </xsl:otherwise>
 198      </xsl:choose>
 199     </xsl:variable>
 200 
 201     <!-- Select content -->
 202     <!--                -->
 203     <xsl:variable name="VarContent" select="$ParamDocument/wwdoc:Document/wwdoc:Content/*[(position() &gt;= $VarStartPosition) and (position() &lt;= $VarEndPosition)]" />
 204 
 205     <xsl:variable name="VarSplitTitle">
 206      <xsl:for-each select="($VarContent[(local-name() = 'Paragraph') and (count(./wwdoc:TextRun/wwdoc:Text) &gt; 0)][1] | $VarContent//wwdoc:Paragraph[not(ancestor::wwdoc:Frame) and (count(./wwdoc:TextRun/wwdoc:Text) &gt; 0)][1])[1]/wwdoc:TextRun/wwdoc:Text">
 207       <xsl:value-of select="@value" />
 208      </xsl:for-each>
 209     </xsl:variable>
 210 
 211     <!-- Split behavior -->
 212     <!--                -->
 213     <xsl:for-each select="$ParamBehaviors[1]">
 214      <xsl:variable name="VarBehaviorsSplit" select="key('wwbehaviors-splits-by-id', $VarSplit/@id)[1]" />
 215 
 216      <!-- Window type -->
 217      <!--             -->
 218      <xsl:variable name="VarWindowType" select="$VarBehaviorsSplit/@window-type" />
 219 
 220      <!-- Name Info -->
 221      <!--           -->
 222      <wwsplits:Split groupID="{$ParamProjectGroup/@GroupID}" documentID="{$ParamProjectDocument/@DocumentID}" id="{$VarSplit/@id}" position="{$VarPosition}" documentstartposition="{$VarStartPosition}" documentendposition="{$VarEndPosition}" title="{$VarSplitTitle}">
 223       <xsl:if test="string-length($VarWindowType) &gt; 0">
 224        <xsl:attribute name="window-type">
 225         <xsl:value-of select="$VarWindowType" />
 226        </xsl:attribute>
 227       </xsl:if>
 228       <wwsplits:Group name="{$ParamProjectGroup/@Name}" id="{$ParamProjectGroup/@GroupID}" position="{$ParamProjectGroupPosition}" />
 229       <wwsplits:Document path="{wwprojext:GetDocumentPath($ParamProjectDocument/@DocumentID)}" id="{$ParamProjectDocument/@DocumentID}" position="{$ParamProjectDocumentPosition}" />
 230 
 231       <!-- Select page markers -->
 232       <!--                     -->
 233       <xsl:variable name="VarPageMarkers" select="$VarContent/wwdoc:Marker | $VarContent//wwdoc:Marker[count(ancestor::wwdoc:Frame[1]) = 0]" />
 234 
 235       <!-- Get last file name marker -->
 236       <!--                           -->
 237       <xsl:variable name="VarPageFileNameMarkersAsXML">
 238        <xsl:call-template name="GetFileNameMarkers">
 239         <xsl:with-param name="ParamBehaviors" select="$ParamBehaviors" />
 240         <xsl:with-param name="ParamMarkers" select="$VarPageMarkers" />
 241        </xsl:call-template>
 242       </xsl:variable>
 243       <xsl:variable name="VarPageFileNameMarkers" select="msxsl:node-set($VarPageFileNameMarkersAsXML)/wwsplits:FileName" />
 244       <xsl:copy-of select="$VarPageFileNameMarkers[count($VarPageFileNameMarkers)]" />
 245 
 246       <!-- Get last page style marker -->
 247       <!--                            -->
 248       <xsl:variable name="VarPageStyle">
 249        <xsl:variable name="VarPageStyleMarkers" select="$VarPageMarkers[@name = 'PageStyle']" />
 250        <xsl:variable name="VarPageStyleMarkersCount" select="count($VarPageStyleMarkers)" />
 251        <xsl:choose>
 252         <xsl:when test="$VarPageStyleMarkersCount &gt; 0">
 253          <xsl:for-each select="$VarPageStyleMarkers[$VarPageStyleMarkersCount]/wwdoc:TextRun/wwdoc:Text">
 254           <xsl:value-of select="@value" />
 255          </xsl:for-each>
 256         </xsl:when>
 257         <xsl:otherwise>
 258          <xsl:value-of select="'Default'" />
 259         </xsl:otherwise>
 260        </xsl:choose>
 261       </xsl:variable>
 262       <wwsplits:PageStyle value="{$VarPageStyle}" />
 263 
 264       <!-- Get frames -->
 265       <!--            -->
 266       <wwsplits:Frames>
 267        <xsl:variable name="VarFrames" select="$VarContent[local-name() = 'Frame'] | $VarContent//wwdoc:Frame[count(ancestor::wwdoc:Frame[1]) = 0]" />
 268        <xsl:for-each select="$VarFrames">
 269         <xsl:variable name="VarFrame" select="." />
 270 
 271         <xsl:variable name="VarFrameTitle">
 272          <xsl:for-each select="$VarFrame/wwdoc:Description/wwdoc:Paragraph[1]/wwdoc:TextRun/wwdoc:Text">
 273           <xsl:value-of select="@value" />
 274          </xsl:for-each>
 275         </xsl:variable>
 276 
 277         <wwsplits:Frame position="{position()}" title="{$VarFrameTitle}">
 278         
 279          <!-- Begin Customization -->
 280          <wwdoc:Frame>
 281           <xsl:copy-of select="$VarFrame/@*[local-name() != 'stylename']" />
 282          
 283           <xsl:variable name="VarStyleName">
 284            <!--xsl:variable name="VarParagraphStyleName" select="$VarFrame/ancestor::wwdoc:Paragraph[1]/@stylename" /-->
 285           
 286            <xsl:choose>
 287             <xsl:when test="contains($VarFrame/@class, 'frame/equation')">
 288              <xsl:text>EquationGraphic</xsl:text>
 289             </xsl:when>
 290            
 291             <xsl:otherwise>
 292              <xsl:value-of select="$VarFrame/@stylename" />
 293             </xsl:otherwise>
 294            </xsl:choose>
 295           </xsl:variable>
 296           
 297           <xsl:variable name="VarLog" select="wwlog:Warning($VarFrame)"/>
 298           
 299           <xsl:attribute name="stylename">
 300            <xsl:value-of select="$VarStyleName" />
 301           </xsl:attribute>
 302          
 303           <xsl:copy-of select="$VarFrame/*" />
 304          
 305          </wwdoc:Frame>
 306          
 307          <!-- End Customization -->
 308          
 309 
 310          <!-- Select frame markers -->
 311          <!--                      -->
 312          <xsl:variable name="VarFrameMarkers" select="$VarFrame//wwdoc:Marker" />
 313 
 314          <!-- Get last file name marker -->
 315          <!--                           -->
 316          <xsl:variable name="VarFrameFileNameMarkersAsXML">
 317           <xsl:call-template name="GetFileNameMarkers">
 318            <xsl:with-param name="ParamBehaviors" select="$ParamBehaviors" />
 319            <xsl:with-param name="ParamMarkers" select="$VarFrameMarkers" />
 320           </xsl:call-template>
 321          </xsl:variable>
 322          <xsl:variable name="VarFrameFileNameMarkers" select="msxsl:node-set($VarFrameFileNameMarkersAsXML)/wwsplits:FileName" />
 323          <xsl:copy-of select="$VarFrameFileNameMarkers[count($VarFrameFileNameMarkers)]" />
 324         </wwsplits:Frame>
 325        </xsl:for-each>
 326       </wwsplits:Frames>
 327 
 328       <!-- Emit Table file names if supported -->
 329       <!--                                    -->
 330       <xsl:if test="$ParameterEmitTableEntries = 'true'">
 331        <wwsplits:Tables>
 332         <xsl:variable name="VarTables" select="$VarBehaviorsSplit//wwbehaviors:Table" />
 333         <xsl:for-each select="$VarTables">
 334          <xsl:variable name="VarTable" select="." />
 335 
 336          <wwsplits:Table groupID="{$ParamProjectGroup/@GroupID}" documentID="{$ParamProjectDocument/@DocumentID}" id="{$VarTable/@id}" position="{position()}" />
 337         </xsl:for-each>
 338        </wwsplits:Tables>
 339       </xsl:if>
 340 
 341       <!-- Emit Popup file names if supported -->
 342       <!--                                    -->
 343       <wwsplits:Popups>
 344        <xsl:variable name="VarPopupDefineParagraphs" select="$VarBehaviorsSplit//wwbehaviors:Paragraph[(@popup = 'define') or (@popup = 'define-no-output')]" />
 345 
 346        <xsl:for-each select="$VarPopupDefineParagraphs">
 347         <xsl:variable name="VarPopupParagraph" select="." />
 348 
 349         <wwsplits:Popup groupID="{$ParamProjectGroup/@GroupID}" documentID="{$ParamProjectDocument/@DocumentID}" id="{$VarPopupParagraph/@id}" stylename="{$VarPopupParagraph/@popup-page-rule}" />
 350        </xsl:for-each>
 351       </wwsplits:Popups>
 352      </wwsplits:Split>
 353     </xsl:for-each>
 354    </xsl:for-each>
 355 
 356   </wwsplits:Splits>
 357  </xsl:template>
 358 </xsl:stylesheet>

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-11-20 19:56:26, 17.5 KB) [[attachment:EquationGraphicCustomCSS.gif]]
  • [get | view] (2009-11-20 19:55:08, 33.6 KB) [[attachment:EquationGraphicStyle.gif]]
  • [get | view] (2009-11-20 19:50:28, 54.1 KB) [[attachment:EquationProblems.gif]]
  • [get | view] (2009-11-20 19:56:48, 39.5 KB) [[attachment:FinishedOutput.gif]]
  • [get | view] (2010-04-02 20:12:16, 3.8 KB) [[attachment:content.xsl]]
  • [get | view] (2009-11-20 19:56:00, 0.1 KB) [[attachment:custom.css]]
  • [get | view] (2010-04-13 21:01:53, 11.4 KB) [[attachment:multiple-equations-after.png]]
  • [get | view] (2010-04-13 21:02:30, 17.1 KB) [[attachment:multiple-equations-after_for-each.png]]
  • [get | view] (2010-04-13 21:01:16, 13.6 KB) [[attachment:multiple-equations-before.png]]
  • [get | view] (2010-04-13 21:02:51, 71.0 KB) [[attachment:multiple-equations-sample.fm]]
  • [get | view] (2009-11-20 19:51:45, 17.5 KB) [[attachment:nameinfo_modified.xsl]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.