ui_engine.xslt 77 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. ##############################################################################
  4. # Copyright (C) 2011 HPCC Systems.
  5. #
  6. # All rights reserved. This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as
  8. # published by the Free Software Foundation, either version 3 of the
  9. # License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. ##############################################################################
  19. -->
  20. <!DOCTYPE xsl:stylesheet [
  21. <!--define the HTML non-breaking space:-->
  22. <!ENTITY nbsp "<xsl:text disable-output-escaping='yes'>&amp;nbsp;</xsl:text>">
  23. ]>
  24. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  25. <xsl:output method="html" encoding="utf-8"/>
  26. <xsl:variable name="debugMode" select="0"/>
  27. <xsl:variable name="filePath">
  28. <xsl:choose>
  29. <xsl:when test="$debugMode">c:/development/bin/debug/files</xsl:when>
  30. <xsl:otherwise>/esp/files_</xsl:otherwise>
  31. </xsl:choose>
  32. </xsl:variable>
  33. <xsl:variable name="Component" select="/*[1]/Component/text()"/>
  34. <xsl:variable name="Command" select="/*[1]/Command/text()"/>
  35. <!--path for componentns.xml must be relative file path oblivious to esp-->
  36. <xsl:variable name="ComponentsDoc" select="document('../files/components.xml')"/>
  37. <xsl:variable name="componentNode" select="$ComponentsDoc/Components/*[name()=$Component]"/>
  38. <xsl:variable name="commandNode" select="$componentNode/Commands/*[name()=$Command]"/>
  39. <xsl:variable name="apos">'</xsl:variable>
  40. <xsl:include href="./ui_overrides.xslt"/>
  41. <xsl:variable name="argsNodeName">
  42. <xsl:choose>
  43. <xsl:when test="$commandNode/@argsNode">
  44. <xsl:value-of select="string($commandNode/@argsNode)"/>
  45. </xsl:when>
  46. <xsl:otherwise>Arguments</xsl:otherwise>
  47. </xsl:choose>
  48. </xsl:variable>
  49. <xsl:variable name="schemaRootNode" select="$commandNode[$argsNodeName='.'] | $commandNode/*[$argsNodeName!='.' and name()=$argsNodeName]"/>
  50. <xsl:variable name="objRootNode" select="/NavMenuEventResponse/XmlArgument | /*[name() != 'NavMenuEventResponse']"/>
  51. <xsl:template match="/">
  52. <xsl:if test="not($ComponentsDoc)">
  53. <xsl:message terminate="yes">Failed to load file components.xml.</xsl:message>
  54. </xsl:if>
  55. <html>
  56. <head>
  57. <title>
  58. <xsl:value-of select="$Command"/>
  59. </title>
  60. <link rel="stylesheet" type="text/css" href="/esp/files/yui/build/fonts/fonts-min.css" />
  61. <link rel="stylesheet" type="text/css" href="/esp/files/css/espdefault.css" />
  62. <link type="text/css" rel="StyleSheet"
  63. href="{$filePath}/css/sortabletable.css"/>
  64. <link type="text/css" rel="StyleSheet" href="{$filePath}/css/tabs.css"/>
  65. <style type="text/css" media="screen">
  66. @import url( <xsl:value-of select="$filePath"/>/css/headerFooter.css );
  67. </style>
  68. <script type="text/javascript" src="/esp/files/scripts/espdefault.js">&#160;</script>
  69. <!--style type="text/css"> - not used any more but save for later
  70. .row-table table {
  71. table-layout:fixed;
  72. font: 10pt arial, helvetica, sans-serif;
  73. border-collapse:collapse;
  74. padding:0;
  75. spacing:0;
  76. margin:0;
  77. }
  78. .row-table td {
  79. padding:0;
  80. spacing:0;
  81. margin:0;
  82. //border:1px solid gray;
  83. border-collapse:collapse;
  84. border:0;
  85. }
  86. .row-table tr {
  87. padding:0;
  88. spacing:0;
  89. margin:0;
  90. //border:0;
  91. //border-collapse:collapse;
  92. }
  93. </style-->
  94. <script type="text/javascript" src="{$filePath}/scripts/CMultiSelect.js">
  95. </script>
  96. <script type="text/javascript" src="{$filePath}/scripts/tooltip.js">
  97. </script>
  98. <script type="text/javascript" src="{$filePath}/popup.js">
  99. </script>
  100. <script type="text/javascript" src="{$filePath}/scripts/ui_engine.js">
  101. </script>
  102. <script type="text/javascript">
  103. <xsl:attribute name="src">
  104. <xsl:value-of select="concat($filePath, '/scripts/')"/>
  105. <xsl:choose>
  106. <xsl:when test="not($commandNode/@nosort='true')">
  107. <xsl:text>sortabletable.js</xsl:text>
  108. </xsl:when>
  109. <xsl:otherwise>
  110. <xsl:text>fixedTables.js</xsl:text>
  111. </xsl:otherwise>
  112. </xsl:choose>
  113. </xsl:attribute>
  114. </script>
  115. </head>
  116. <body class="yui-skin-sam" onload="nof5();loadCommandInfo()" onmousemove="overhere()" bgcolor="white">
  117. <xsl:copy-of select="$commandNode/script"/>
  118. <xsl:if test="string($commandNode/@selectedTab)">
  119. <xsl:apply-templates select="$componentNode/TabContainer">
  120. <xsl:with-param name="selectedTab" select="$commandNode/@selectedTab"/>
  121. </xsl:apply-templates>
  122. </xsl:if>
  123. <xsl:if test="string($commandNode/@schemaIsland)!='false'">
  124. <xsl:call-template name="makeSchemaDataIsland"/>
  125. </xsl:if>
  126. <xsl:if test="not($commandNode/@objIsland='')">
  127. <xsl:call-template name="makeArgsDataIsland">
  128. <xsl:with-param name="elementName" select="string($commandNode/@objIsland)"/>
  129. </xsl:call-template>
  130. </xsl:if>
  131. <form method="post" onsubmit="return onSubmit()">
  132. <xsl:copy-of select="$schemaRootNode/@enctype"/>
  133. <xsl:attribute name="action">
  134. <xsl:choose>
  135. <xsl:when test="$commandNode/@action">
  136. <xsl:value-of select="$commandNode/@action"/>
  137. </xsl:when>
  138. <xsl:otherwise>
  139. <xsl:value-of select="concat('/', $Component, '/', $Command)"/>
  140. </xsl:otherwise>
  141. </xsl:choose>
  142. </xsl:attribute>
  143. <div id="pageBody">
  144. <div id="ToolTip" style="position:absolute;left:0;top:0;visibility:hidden"/>
  145. <xsl:apply-templates select="$componentNode">
  146. <xsl:with-param name="ObjNode" select="$objRootNode"/>
  147. </xsl:apply-templates>
  148. </div>
  149. <xsl:for-each select="$commandNode/Buttons[1]">
  150. <div id="pageFooter">
  151. <xsl:call-template name="createButtons">
  152. <xsl:with-param name="btnsNode" select="."/>
  153. </xsl:call-template>
  154. </div>
  155. </xsl:for-each>
  156. </form>
  157. </body>
  158. </html>
  159. </xsl:template>
  160. <xsl:template match="TabContainer">
  161. <xsl:param name="selectedTab"/>
  162. <div id="pageHeader">
  163. <div id="tabContainer" width="100%">
  164. <ul id="tabNavigator">
  165. <xsl:for-each select="Tab">
  166. <li>
  167. <a href="{@url}">
  168. <xsl:if test="@name=$selectedTab">
  169. <xsl:attribute name="class">active</xsl:attribute>
  170. </xsl:if>
  171. <xsl:value-of select="@name"/>
  172. </a>
  173. </li>
  174. </xsl:for-each>
  175. </ul>
  176. </div>
  177. </div>
  178. </xsl:template>
  179. <xsl:template name="makeSchemaDataIsland">
  180. <xml id="xmlSchema" style="display:none;">
  181. <xsl:element name="Components">
  182. <xsl:element name="{$Component}">
  183. <xsl:apply-templates select="$componentNode/Defaults" mode="copy"/>
  184. <xsl:element name="Commands">
  185. <xsl:for-each select="$commandNode">
  186. <xsl:copy>
  187. <xsl:copy-of select="@*"/>
  188. <xsl:choose>
  189. <xsl:when test="$argsNodeName='.'">
  190. <xsl:copy-of select="*[name()!='Component' and name() != 'Command' and name()!='script']"/>
  191. </xsl:when>
  192. <xsl:otherwise>
  193. <xsl:copy-of select="*[name()!='script' and name()!='Buttons']" />
  194. </xsl:otherwise>
  195. </xsl:choose>
  196. </xsl:copy>
  197. </xsl:for-each>
  198. </xsl:element>
  199. </xsl:element>
  200. </xsl:element>
  201. </xml>
  202. <input type="hidden" name="xmlArgs" value=""/>
  203. </xsl:template>
  204. <xsl:template name="makeArgsDataIsland">
  205. <xsl:param name="elementName"/>
  206. <div style="display:none;">
  207. <xml id="xmlPrevArgsDoc" >
  208. <PrevArgsDoc>
  209. <xsl:for-each select="$objRootNode">
  210. <xsl:variable name="inputFragment" select="*[$argsNodeName!='.' and name() = $argsNodeName][1]"/>
  211. <xsl:choose>
  212. <xsl:when test="$elementName!=''">
  213. <xsl:copy-of select="*[name()=$elementName]"/>
  214. </xsl:when>
  215. <xsl:when test="$inputFragment">
  216. <xsl:copy-of select="$inputFragment"/>
  217. </xsl:when>
  218. <xsl:when test="$argsNodeName='.'">
  219. <xsl:element name="{$Command}">
  220. <xsl:copy-of select="@*|*[name() != 'Component' and name() != 'Command']"/>
  221. </xsl:element>
  222. </xsl:when>
  223. <xsl:otherwise>
  224. <xsl:element name="{$argsNodeName}"/>
  225. </xsl:otherwise>
  226. </xsl:choose>
  227. </xsl:for-each>
  228. </PrevArgsDoc>
  229. </xml>
  230. </div>
  231. </xsl:template>
  232. <xsl:template match="Components/*">
  233. <xsl:param name="ObjNode"/>
  234. <xsl:if test="not($commandNode)">
  235. <xsl:message terminate="yes">Command '<xsl:value-of select="$Command"/>' is not defined in components.xml file!"/></xsl:message>
  236. </xsl:if>
  237. <input type="hidden" id="component" name="comp" value="{$Component}"/>
  238. <input type="hidden" id="command" name="command" value="{$Command}"/>
  239. <br/>
  240. <!--define a table that is dynamically filled up using DOM / DHTML using javascript -->
  241. <xsl:if test="$commandNode/@caption">
  242. <h3 id="pageCaption">
  243. <xsl:value-of select="$commandNode/@caption"/>
  244. </h3>
  245. </xsl:if>
  246. <xsl:if test="string($commandNode/@subcaption)!=''">
  247. <h4 id="pageSubCaption">
  248. <xsl:value-of select="$commandNode/@subcaption"/>
  249. </h4>
  250. </xsl:if>
  251. <xsl:for-each select="$commandNode">
  252. <xsl:if test="$schemaRootNode/@maxOccurs='unbounded'">
  253. <xsl:call-template name="createColumnHeaders">
  254. <xsl:with-param name="tableId" select="'ArgsTable'"/>
  255. <xsl:with-param name="rowId" select="'ArgsTable.header'"/>
  256. <xsl:with-param name="targetNode" select="$objRootNode"/>
  257. <xsl:with-param name="schemaNode" select="$schemaRootNode"/>
  258. <xsl:with-param name="xpath" select="''"/>
  259. </xsl:call-template>
  260. </xsl:if>
  261. <xsl:call-template name="populateTable">
  262. <xsl:with-param name="tableId" select="'ArgsTable'"/>
  263. <xsl:with-param name="schemaNode" select="$schemaRootNode"/>
  264. <xsl:with-param name="targetNode" select="$objRootNode"/>
  265. <xsl:with-param name="xPath" select="''"/>
  266. </xsl:call-template>
  267. </xsl:for-each>
  268. </xsl:template>
  269. <xsl:template name="populateTable">
  270. <xsl:param name="tableId"/>
  271. <xsl:param name="schemaNode"/>
  272. <xsl:param name="targetNode"/>
  273. <xsl:param name="xpath"/>
  274. <xsl:variable name="columnCount">
  275. <xsl:call-template name="countColumns">
  276. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  277. </xsl:call-template>
  278. </xsl:variable>
  279. <!--display "- none -" if $targetNode is empty-->
  280. <xsl:variable name="name" select="name($schemaNode)"/>
  281. <xsl:choose>
  282. <xsl:when test="not($targetNode/*[name()=$name][1]) and $schemaNode/@maxOccurs='unbounded'">
  283. <tr>
  284. <td colspan="{$columnCount}">- none -</td>
  285. </tr>
  286. </xsl:when>
  287. <xsl:otherwise>
  288. <xsl:call-template name="addTableRows">
  289. <xsl:with-param name="tableId" select="$tableId"/>
  290. <xsl:with-param name="objNode" select="$targetNode"/>
  291. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  292. <xsl:with-param name="xpath" select="$xpath"/>
  293. <xsl:with-param name="columnCount" select="$columnCount"/>
  294. </xsl:call-template>
  295. </xsl:otherwise>
  296. </xsl:choose>
  297. </xsl:template>
  298. <xsl:template name="makeNextXPath">
  299. <xsl:param name="schemaNode"/>
  300. <xsl:param name="xpath"/>
  301. <xsl:if test="string($xpath)!=''">
  302. <xsl:value-of select="$xpath"/>
  303. </xsl:if>
  304. <xsl:if test="not($schemaNode/@nodeName='')"><!--if not(exists and is '')-->
  305. <xsl:if test="string($xpath)!=''">
  306. <xsl:text>.</xsl:text>
  307. </xsl:if>
  308. <xsl:choose>
  309. <xsl:when test="$schemaNode/@nodeName">
  310. <xsl:value-of select="$schemaNode/@nodeName"/>
  311. </xsl:when>
  312. <xsl:otherwise>
  313. <xsl:value-of select="name($schemaNode)"/>
  314. </xsl:otherwise>
  315. </xsl:choose>
  316. </xsl:if>
  317. </xsl:template>
  318. <xsl:template name="createColumnHeaders">
  319. <xsl:param name="tableId"/>
  320. <xsl:param name="rowId"/>
  321. <xsl:param name="targetNode"/>
  322. <xsl:param name="schemaNode"/>
  323. <xsl:param name="xpath"/>
  324. <xsl:param name="nChildElements"/>
  325. <xsl:variable name="xpath2">
  326. <xsl:if test="name($schemaNode[1])!=name($schemaRootNode[1])">
  327. <xsl:call-template name="makeNextXPath">
  328. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  329. <xsl:with-param name="xpath" select="$xpath"/>
  330. </xsl:call-template>
  331. </xsl:if>
  332. </xsl:variable>
  333. <xsl:variable name="maxOccurs" select="$schemaNode/@maxOccurs"/>
  334. <xsl:if test="$maxOccurs">
  335. <xsl:variable name="numCheckColumn">
  336. <xsl:choose>
  337. <xsl:when test="string($maxOccurs)='unbounded' and string($schemaNode/@checkboxes)!='false'">1</xsl:when>
  338. <xsl:otherwise>0</xsl:otherwise>
  339. </xsl:choose>
  340. </xsl:variable>
  341. <xsl:if test="$numCheckColumn=1">
  342. <th width="35">
  343. <xsl:choose>
  344. <xsl:when test="string($schemaNode/@multiselect)='true'">
  345. <xsl:attribute name="id">
  346. <xsl:value-of select="concat($tableId, '_ms0_T')"/>
  347. </xsl:attribute>
  348. <input type="checkbox" value="1" title="Select or unselect all items">
  349. <xsl:if test="$schemaNode/@checked">
  350. <xsl:attribute name="checked">true</xsl:attribute>
  351. </xsl:if>
  352. <xsl:attribute name="onclick">
  353. <xsl:value-of select="concat('ms_setAll(this, ', $apos, $tableId, $apos, ',0)')"/>
  354. </xsl:attribute>
  355. <xsl:if test="not($targetNode/*[name()=name($schemaNode)][2])">
  356. <xsl:attribute name="disabled">true</xsl:attribute>
  357. </xsl:if>
  358. </input>
  359. </xsl:when>
  360. <xsl:otherwise>&nbsp;</xsl:otherwise>
  361. </xsl:choose>
  362. <script type="text/javascript">
  363. var ms = ms_create('<xsl:value-of select="$tableId"/>', onRowCheck );
  364. <xsl:if test="string($schemaNode/@multiselect)!='true'">
  365. ms.b_singleSelect = true;
  366. </xsl:if>
  367. </script>
  368. </th>
  369. </xsl:if>
  370. <xsl:if test="string($maxOccurs)='unbounded' or string($xpath)!=''">
  371. <xsl:variable name="childObjNode" select="$targetNode/*[name()=name($schemaNode)][1]"/>
  372. <xsl:for-each select="$schemaNode/*[name()!='Buttons' and name()!='script']">
  373. <xsl:variable name="name" select="name()"/>
  374. <!--any of our siblings which is either a visible attribute or a node with the same holds a column so count them-->
  375. <xsl:choose>
  376. <xsl:when test="string(@maxOccurs)='1'">
  377. <xsl:choose>
  378. <xsl:when test="@table">
  379. <xsl:if test="@caption and not($argsNodeName='.' and name()=name($schemaRootNode))">
  380. <th>
  381. <xsl:copy-of select="@width"/>
  382. <xsl:value-of select="@caption"/>
  383. </th>
  384. </xsl:if>
  385. </xsl:when>
  386. <xsl:otherwise>
  387. <xsl:call-template name="createColumnHeaders">
  388. <xsl:with-param name="tableId" select="$tableId"/>
  389. <xsl:with-param name="rowId" select="$rowId"/>
  390. <xsl:with-param name="targetNode" select="$childObjNode"/>
  391. <xsl:with-param name="schemaNode" select="."/>
  392. <xsl:with-param name="xpath" select="$xpath2"/>
  393. <xsl:with-param name="nChildElements" select="$nChildElements"/>
  394. </xsl:call-template>
  395. </xsl:otherwise>
  396. </xsl:choose>
  397. </xsl:when>
  398. <xsl:when test="not(@maxOccurs)"><!--attribute definition-->
  399. <xsl:variable name="viewType" select="@viewType"/>
  400. <xsl:if test="string($viewType)!='hidden'">
  401. <xsl:variable name="caption">
  402. <xsl:choose>
  403. <xsl:when test="@caption">
  404. <xsl:value-of select="@caption"/>
  405. </xsl:when>
  406. <xsl:otherwise>
  407. <xsl:value-of select="$name"/>
  408. </xsl:otherwise>
  409. </xsl:choose>
  410. </xsl:variable>
  411. <th>
  412. <xsl:copy-of select="@width"/>
  413. <xsl:variable name="nodeName" select="name()"/>
  414. <xsl:variable name="dataNode" select="$childObjNode/*[name()=$nodeName][1]"/>
  415. <xsl:variable name="nRows" select="count($childObjNode/*[name()=current()/@name])"/>
  416. <xsl:variable name="popupPrefix" select="concat('return showColumnPopup(', $apos, $tableId, $apos, ', this.cellIndex')"/>
  417. <xsl:choose>
  418. <xsl:when test="($nRows=0 or $nRows>1) and string(@multiselect)='true'">
  419. <xsl:variable name="msId" select="concat($tableId, '_ms', string(@column), '_T')"/>
  420. <xsl:attribute name="id">
  421. <xsl:value-of select="$msId"/>
  422. </xsl:attribute>
  423. <xsl:attribute name="oncontextmenu">
  424. <xsl:value-of select="concat($popupPrefix, ', toggleMultiSelect)')"/>
  425. </xsl:attribute>
  426. <xsl:value-of select="$caption"/>
  427. <xsl:call-template name="createInputControlForNode">
  428. <xsl:with-param name="tableId" select="$tableId"/>
  429. <xsl:with-param name="rowId" select="$rowId"/>
  430. <xsl:with-param name="idPrefix" select="$xpath"/>
  431. <xsl:with-param name="node" select="$dataNode"/>
  432. <xsl:with-param name="schemaNode" select="."/>
  433. <xsl:with-param name="dataType" select="@dataType"/>
  434. <xsl:with-param name="viewType" select="@viewType"/>
  435. <xsl:with-param name="multiselect" select="1"/>
  436. <xsl:with-param name="columnHeader" select="1"/>
  437. </xsl:call-template>
  438. </xsl:when>
  439. <xsl:otherwise>
  440. <xsl:attribute name="oncontextmenu"><xsl:value-of select="$popupPrefix"/>)</xsl:attribute>
  441. <xsl:value-of select="$caption"/>
  442. </xsl:otherwise>
  443. </xsl:choose>
  444. </th>
  445. </xsl:if>
  446. </xsl:when><!--attribute definition-->
  447. </xsl:choose>
  448. </xsl:for-each>
  449. </xsl:if>
  450. </xsl:if><!--maxOccurs is defined-->
  451. </xsl:template>
  452. <xsl:template name="tallyColumns">
  453. <xsl:param name="schemaNode"/>
  454. <xsl:choose>
  455. <xsl:when test="not($schemaNode/@maxOccurs)">
  456. <xsl:if test="string($schemaNode/@viewType)!='hidden'">1</xsl:if>
  457. </xsl:when>
  458. <xsl:when test="string($schemaNode/@maxOccurs)='1'">
  459. <xsl:for-each select="$schemaNode/*[name()!='Buttons' and name()!='script']">
  460. <xsl:call-template name="tallyColumns">
  461. <xsl:with-param name="schemaNode" select="."/>
  462. </xsl:call-template>
  463. </xsl:for-each>
  464. </xsl:when>
  465. <xsl:otherwise><!--maxOccurs='unbounded'-->
  466. <xsl:if test="string($schemaNode/@checkboxes)!='false'">1</xsl:if>
  467. </xsl:otherwise>
  468. </xsl:choose>
  469. </xsl:template>
  470. <xsl:template name="countColumns">
  471. <xsl:param name="schemaNode"/>
  472. <xsl:variable name="columnTally">
  473. <xsl:if test="string($schemaNode/@maxOccurs)='unbounded' and string($schemaNode/@checkboxes)!='false'">
  474. <xsl:text>1</xsl:text>
  475. </xsl:if>
  476. <xsl:for-each select="$schemaNode/*[name()!='Buttons' and name()!='script' and not(@break)]">
  477. <xsl:call-template name="tallyColumns">
  478. <xsl:with-param name="schemaNode" select="."/>
  479. </xsl:call-template>
  480. </xsl:for-each>
  481. </xsl:variable>
  482. <xsl:choose>
  483. <xsl:when test="$columnTally=''">1</xsl:when>
  484. <xsl:otherwise>
  485. <xsl:value-of select="string-length($columnTally)"/>
  486. </xsl:otherwise>
  487. </xsl:choose>
  488. </xsl:template>
  489. <xsl:template name="createButtons">
  490. <xsl:param name="btnsNode"/>
  491. <center>
  492. <xsl:for-each select="$btnsNode/*">
  493. <xsl:if test="position()!=1">&nbsp;</xsl:if>
  494. <xsl:copy>
  495. <xsl:copy-of select="@*[name()!='override']"/>
  496. <xsl:if test="@override">
  497. <xsl:apply-templates select="." mode="override"/>
  498. </xsl:if>
  499. <xsl:apply-templates select="*|text()" mode="copy"/>
  500. </xsl:copy>
  501. </xsl:for-each>
  502. </center>
  503. </xsl:template>
  504. <xsl:template name="createFixedTableWithHeader">
  505. <xsl:param name="schemaNode"/>
  506. <xsl:param name="targetNode"/>
  507. <xsl:param name="tableId"/>
  508. <xsl:param name="xpath"/>
  509. <xsl:param name="width"/>
  510. <xsl:choose>
  511. <xsl:when test="not($schemaNode/@splitTable='false')">
  512. <xsl:if test="$schemaNode/@maxOccurs='unbounded' or $xpath!=''">
  513. <div class="TableHeaderDiv" id="DH.{$tableId}">
  514. <script type="text/javascript">
  515. a_fixedTableNames.push('<xsl:value-of select="$tableId"/>');
  516. </script>
  517. <table id="H.{$tableId}">
  518. <xsl:if test="$width and string($width)!='100%'">
  519. <xsl:attribute name="style">table-layout:fixed</xsl:attribute>
  520. <xsl:attribute name="width"><xsl:value-of select="$width"/></xsl:attribute>
  521. </xsl:if>
  522. <thead>
  523. <tr>
  524. <xsl:call-template name="createColumnHeaders">
  525. <xsl:with-param name="tableId" select="$tableId"/>
  526. <xsl:with-param name="rowId" select="concat($tableId, '.header')"/>
  527. <xsl:with-param name="targetNode" select="$targetNode"/>
  528. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  529. <xsl:with-param name="xpath" select="$xpath"/>
  530. </xsl:call-template>
  531. </tr>
  532. </thead>
  533. </table>
  534. </div>
  535. </xsl:if>
  536. <div class="TableBodyDiv" id="DB.{$tableId}">
  537. <table id="{$tableId}">
  538. <xsl:if test="$width and string($width)!='100%'">
  539. <xsl:attribute name="style">table-layout:fixed</xsl:attribute>
  540. <xsl:attribute name="width"><xsl:value-of select="$width"/></xsl:attribute>
  541. </xsl:if>
  542. <tbody>
  543. <xsl:call-template name="populateTable">
  544. <xsl:with-param name="tableId" select="$tableId"/>
  545. <xsl:with-param name="targetNode" select="$targetNode"/>
  546. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  547. <xsl:with-param name="xpath" select="$xpath"/>
  548. </xsl:call-template>
  549. </tbody>
  550. </table>
  551. </div>
  552. </xsl:when>
  553. <xsl:otherwise>
  554. <table id="{$tableId}" class="sort-table">
  555. <xsl:if test="$width and string($width)!='100%'">
  556. <xsl:attribute name="style">table-layout:fixed</xsl:attribute>
  557. <xsl:attribute name="width"><xsl:value-of select="$width"/></xsl:attribute>
  558. </xsl:if>
  559. <thead>
  560. <xsl:if test="$schemaNode/@maxOccurs='unbounded' or $xpath!=''">
  561. <tr style="background:lightgrey">
  562. <xsl:call-template name="createColumnHeaders">
  563. <xsl:with-param name="tableId" select="$tableId"/>
  564. <xsl:with-param name="rowId" select="concat($tableId, '.header')"/>
  565. <xsl:with-param name="targetNode" select="$targetNode"/>
  566. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  567. <xsl:with-param name="xpath" select="$xpath"/>
  568. </xsl:call-template>
  569. </tr>
  570. </xsl:if>
  571. </thead>
  572. <tbody>
  573. <xsl:call-template name="populateTable">
  574. <xsl:with-param name="tableId" select="$tableId"/>
  575. <xsl:with-param name="targetNode" select="$targetNode"/>
  576. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  577. <xsl:with-param name="xpath" select="$xpath"/>
  578. </xsl:call-template>
  579. </tbody>
  580. </table>
  581. </xsl:otherwise>
  582. </xsl:choose>
  583. </xsl:template>
  584. <xsl:template name="createFixedTable">
  585. <xsl:param name="schemaNode"/>
  586. <xsl:param name="targetNode"/>
  587. <xsl:param name="id"/>
  588. <xsl:param name="tableId"/>
  589. <xsl:param name="xpath"/>
  590. <xsl:param name="columnCount"/>
  591. <xsl:if test="not($schemaNode/@splitTable='false')">
  592. <xsl:text disable-output-escaping="yes">&lt;div class="TableBodyDiv" id="DB.</xsl:text>
  593. <xsl:value-of select="$id"/>
  594. <xsl:text disable-output-escaping="yes">"&gt;</xsl:text>
  595. <script type="text/javascript">
  596. a_fixedTableNames.push('<xsl:value-of select="$id"/>');
  597. </script>
  598. </xsl:if>
  599. <table id="{$id}">
  600. <xsl:copy-of select="$schemaNode/@width|$schemaNode/@style"/>
  601. <tbody>
  602. <xsl:for-each select="$schemaNode/*[name()!='Buttons' and name()!='script']">
  603. <xsl:call-template name="addTableRows">
  604. <xsl:with-param name="tableId" select="$tableId"/>
  605. <xsl:with-param name="objNode" select="$targetNode"/>
  606. <xsl:with-param name="schemaNode" select="."/>
  607. <xsl:with-param name="xpath" select="$xpath"/>
  608. <xsl:with-param name="columnCount" select="$columnCount"/>
  609. </xsl:call-template>
  610. </xsl:for-each>
  611. </tbody>
  612. </table>
  613. <xsl:if test="not($schemaNode/@splitTable='false')">
  614. <xsl:text disable-output-escaping="yes">&lt;/div&gt;</xsl:text>
  615. </xsl:if>
  616. </xsl:template>
  617. <xsl:template name="addTableRows">
  618. <xsl:param name="tableId"/>
  619. <xsl:param name="objNode"/>
  620. <xsl:param name="schemaNode"/>
  621. <xsl:param name="xpath"/>
  622. <xsl:param name="columnCount"/>
  623. <xsl:param name="showTableCaption" select="1"/>
  624. <xsl:variable name="name" select="name($schemaNode)"/>
  625. <xsl:variable name="maxOccurs" select="$schemaNode/@maxOccurs"/>
  626. <xsl:variable name="xpath2">
  627. <xsl:if test="name($schemaNode)!=name($schemaRootNode) or $argsNodeName!='Arguments'">
  628. <xsl:call-template name="makeNextXPath">
  629. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  630. <xsl:with-param name="xpath" select="$xpath"/>
  631. </xsl:call-template>
  632. </xsl:if>
  633. </xsl:variable>
  634. <xsl:choose>
  635. <xsl:when test="string($maxOccurs)='unbounded'">
  636. <xsl:choose>
  637. <xsl:when test="string($tableId)!=string($xpath2)">
  638. <xsl:if test="$schemaNode/@colspan">
  639. <xsl:text disable-output-escaping="yes">&lt;tr&gt;&lt;td colspan="</xsl:text>
  640. <xsl:value-of select="$schemaNode/@colspan"/>
  641. <xsl:text disable-output-escaping="yes">" style="text-align:left"&gt;</xsl:text>
  642. </xsl:if>
  643. <!-- create another table that would occupy entire cell of the parent table's row-->
  644. <xsl:if test="$schemaNode/@break='true'">
  645. <br/>
  646. </xsl:if>
  647. <xsl:if test="$schemaNode/@caption and not($argsNodeName='.' and name($schemaNode)=name($schemaRootNode))">
  648. <b align="left"><xsl:value-of select="$schemaNode/@caption"/></b>
  649. </xsl:if>
  650. <xsl:variable name="tableWidth">
  651. <xsl:choose>
  652. <xsl:when test="$schemaNode/@width and string($schemaNode/@width)!='100%'">
  653. <xsl:choose>
  654. <xsl:when test="not($schemaNode/@checkboxes='false')">
  655. <xsl:value-of select="number($schemaNode/@width)+35"/>
  656. </xsl:when>
  657. <xsl:otherwise>
  658. <xsl:value-of select="number($schemaNode/@width)"/>
  659. </xsl:otherwise>
  660. </xsl:choose>
  661. </xsl:when>
  662. <xsl:otherwise>
  663. <xsl:attribute name="width">100%</xsl:attribute>
  664. </xsl:otherwise>
  665. </xsl:choose>
  666. </xsl:variable>
  667. <xsl:call-template name="createFixedTableWithHeader">
  668. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  669. <xsl:with-param name="targetNode" select="$objNode"/>
  670. <xsl:with-param name="tableId" select="$xpath2"/>
  671. <xsl:with-param name="xpath" select="$xpath"/>
  672. <xsl:with-param name="width" select="$tableWidth"/>
  673. </xsl:call-template>
  674. <xsl:if test="$schemaNode/../@table">
  675. <xsl:text disable-output-escaping="yes">&lt;/td&gt;&lt;/tr&gt;</xsl:text>
  676. </xsl:if>
  677. <!--xsl:call-template name="createButtons">
  678. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  679. <xsl:with-param name="targetNode" select="$objNode"/>
  680. </xsl:call-template-->
  681. </xsl:when>
  682. <xsl:otherwise><!--tableId == xpath2-->
  683. <xsl:variable name="rowCheckbox" select="string($schemaNode/@checkboxes)!='false'"/>
  684. <xsl:variable name="checked" select="string($schemaNode/@checked)='true'"/>
  685. <xsl:variable name="itemListValue">
  686. <xsl:text>+</xsl:text>
  687. <xsl:for-each select="$objNode/*[name()=$name]">
  688. <xsl:value-of select="position()-1"/>
  689. <xsl:text>+</xsl:text>
  690. </xsl:for-each>
  691. </xsl:variable>
  692. <input type="hidden" id="{$tableId}.itemlist"
  693. name="{$tableId}.itemlist" value="{$itemListValue}"/>
  694. <xsl:for-each select="$objNode/*[name()=$name]">
  695. <xsl:variable name="rowId" select="concat($xpath2, '.', string(position()-1))"/>
  696. <tr id="{$rowId}">
  697. <xsl:if test="string($schemaNode/@hover)!='false'">
  698. <xsl:attribute name="onmouseenter">this.bgColor='#F0F0FF'</xsl:attribute>
  699. <xsl:choose>
  700. <xsl:when test="position() mod 2">
  701. <xsl:attribute name="bgColor">#FFFFFF</xsl:attribute>
  702. <xsl:attribute name="onmouseleave">this.bgColor = '#FFFFFF'</xsl:attribute>
  703. </xsl:when>
  704. <xsl:otherwise>
  705. <xsl:attribute name="bgColor">#F0F0F0</xsl:attribute>
  706. <xsl:attribute name="onmouseleave">this.bgColor = '#F0F0F0'</xsl:attribute>
  707. </xsl:otherwise>
  708. </xsl:choose>
  709. </xsl:if>
  710. <!--xsl:choose> - not used any more but save for future
  711. <xsl:when test="$schemaNode/@tableRows">
  712. <td colspan="{$columnCount}" class="row-table">
  713. <table border="0" class="row-table" width="100%">
  714. <tbody>
  715. <tr>
  716. <xsl:call-template name="populateTableRow">
  717. <xsl:with-param name="tableId" select="$tableId"/>
  718. <xsl:with-param name="rowId" select="$rowId"/>
  719. <xsl:with-param name="domNode" select="."/>
  720. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  721. <xsl:with-param name="xpath" select="$xpath2"/>
  722. <xsl:with-param name="bRowCheckbox" select="$rowCheckbox"/>
  723. <xsl:with-param name="bChecked" select="$checked"/>
  724. </xsl:call-template>
  725. </tr>
  726. </tbody>
  727. </table>
  728. <xsl:variable name="objNode2" select="."/>
  729. <xsl:for-each select="$schemaNode/*[@break]">
  730. <br/>
  731. <xsl:variable name="columnCount2">
  732. <xsl:call-template name="countColumns">
  733. <xsl:with-param name="schemaNode" select="."/>
  734. </xsl:call-template>
  735. </xsl:variable>
  736. <xsl:call-template name="addTableRows">
  737. <xsl:with-param name="tableId" select="$tableId"/>
  738. <xsl:with-param name="objNode" select="$objNode2"/>
  739. <xsl:with-param name="schemaNode" select="."/>
  740. <xsl:with-param name="xpath" select="$rowId"/>
  741. <xsl:with-param name="columnCount" select="$columnCount2"/>
  742. </xsl:call-template>
  743. </xsl:for-each>
  744. </td>
  745. </xsl:when>
  746. <xsl:otherwise-->
  747. <xsl:call-template name="populateTableRow">
  748. <xsl:with-param name="tableId" select="$tableId"/>
  749. <xsl:with-param name="rowId" select="$rowId"/>
  750. <xsl:with-param name="domNode" select="."/>
  751. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  752. <xsl:with-param name="xpath" select="$xpath2"/>
  753. <xsl:with-param name="bRowCheckbox" select="$rowCheckbox"/>
  754. <xsl:with-param name="bChecked" select="$checked"/>
  755. </xsl:call-template>
  756. <!--/xsl:otherwise>
  757. </xsl:choose-->
  758. </tr>
  759. </xsl:for-each>
  760. </xsl:otherwise>
  761. </xsl:choose>
  762. </xsl:when>
  763. <xsl:when test="string($maxOccurs)='1' or name($schemaNode)=name($schemaRootNode)">
  764. <xsl:variable name="rootName" select="name($schemaRootNode)"/>
  765. <xsl:variable name="targetNode"
  766. select="$objNode/*[name()=$name and ($argsNodeName!='.' or $name!=$rootName)][1]|$objNode[$argsNodeName='.' and $name=$rootName]"/>
  767. <xsl:if test="not($targetNode)">
  768. <!--TODO-->
  769. </xsl:if>
  770. <xsl:choose>
  771. <xsl:when test="$schemaNode/@table">
  772. <!--create another table that would occupy entire cell of parent table's row -->
  773. <xsl:variable name="nestedTableWidth">
  774. <xsl:choose>
  775. <xsl:when test="@width">
  776. <xsl:value-of select="@width"/>
  777. </xsl:when>
  778. <xsl:otherwise>100%</xsl:otherwise>
  779. </xsl:choose>
  780. </xsl:variable>
  781. <!--tr-->
  782. <xsl:choose>
  783. <xsl:when test="$schemaNode/../@maxOccurs='unbounded'">
  784. <xsl:text disable-output-escaping="yes">&lt;td style="padding:0" width="</xsl:text>
  785. <xsl:value-of select="$nestedTableWidth"/>
  786. <xsl:text disable-output-escaping="yes">"&gt;</xsl:text>
  787. </xsl:when>
  788. <xsl:when test="$schemaNode/@break">
  789. <br/>
  790. </xsl:when>
  791. </xsl:choose>
  792. <xsl:variable name="tableId2">
  793. <!--xsl:if test="not($schemaNode/@id='')"--><!--not(exists and is '')-->
  794. <xsl:choose>
  795. <xsl:when test="$schemaNode/@id">
  796. <xsl:value-of select="$schemaNode/@id"/>
  797. </xsl:when>
  798. <xsl:otherwise>
  799. <xsl:value-of select="$xpath2"/>
  800. </xsl:otherwise>
  801. </xsl:choose>
  802. <!--/xsl:if-->
  803. </xsl:variable>
  804. <xsl:variable name="caption" select="$schemaNode/@caption"/>
  805. <xsl:if test="$showTableCaption and $caption and not($argsNodeName='.' and name($schemaNode)=name($schemaRootNode))">
  806. <b align="left"><xsl:value-of select="$caption"/></b>
  807. </xsl:if>
  808. <!--border="0" style="font: 10pt arial, helvetica, sans-serif;"-->
  809. <xsl:call-template name="createFixedTable">
  810. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  811. <xsl:with-param name="targetNode" select="$targetNode"/>
  812. <xsl:with-param name="id" select="$tableId2"/>
  813. <xsl:with-param name="tableId" select="$tableId"/>
  814. <xsl:with-param name="xpath" select="$xpath2"/>
  815. <xsl:with-param name="columnCount" select="$columnCount"/>
  816. </xsl:call-template>
  817. <xsl:if test="$schemaNode/@overrideCell='after'">
  818. <xsl:apply-templates select="$schemaNode" mode="overrideCell">
  819. <xsl:with-param name="objNode" select="$targetNode"/>
  820. <xsl:with-param name="rowId" select="$xpath2"/>
  821. <xsl:with-param name="columnHeader" select="0"/>
  822. </xsl:apply-templates>
  823. </xsl:if>
  824. <xsl:if test="$schemaNode/../@maxOccurs='unbounded'">
  825. <xsl:text disable-output-escaping="yes">&lt;/td&gt;</xsl:text>
  826. </xsl:if>
  827. <!--/tr-->
  828. </xsl:when>
  829. <xsl:otherwise>
  830. <xsl:for-each select="$schemaNode/*[name()!='Buttons' and name()!='script']">
  831. <xsl:call-template name="addTableRows">
  832. <xsl:with-param name="tableId" select="$tableId"/>
  833. <xsl:with-param name="objNode" select="$targetNode"/>
  834. <xsl:with-param name="schemaNode" select="."/>
  835. <xsl:with-param name="xpath" select="$xpath2"/>
  836. <xsl:with-param name="columnCount" select="$columnCount"/>
  837. </xsl:call-template>
  838. </xsl:for-each>
  839. </xsl:otherwise>
  840. </xsl:choose>
  841. </xsl:when>
  842. <xsl:otherwise><!--an attribute-->
  843. <xsl:variable name="targetNode" select="$objNode/*[name()=$name][1]"/>
  844. <xsl:if test="not($targetNode)">
  845. <!--TODO-->
  846. </xsl:if>
  847. <xsl:variable name="rowId" select="concat($tableId, '.', name($schemaNode))"/>
  848. <xsl:choose>
  849. <xsl:when test="string($schemaNode/@viewType)!='hidden'">
  850. <xsl:variable name="caption">
  851. <xsl:choose>
  852. <xsl:when test="$schemaNode/@caption">
  853. <xsl:value-of select="$schemaNode/@caption"/>
  854. </xsl:when>
  855. <xsl:otherwise>
  856. <xsl:value-of select="name($schemaNode)"/>
  857. </xsl:otherwise>
  858. </xsl:choose>
  859. </xsl:variable>
  860. <tr><!--id="{$rowId}.row" is this needed?-->
  861. <th width="1%" style="border:0;text-align:left">
  862. <xsl:copy-of select="$schemaNode/@noWrap"/>
  863. <xsl:value-of select="$caption"/>
  864. </th>
  865. <td width="1%"><b>:</b></td>
  866. <td>
  867. <xsl:call-template name="insertAttribNodeInRow">
  868. <xsl:with-param name="tableId" select="$tableId"/>
  869. <xsl:with-param name="rowId" select="$rowId"/>
  870. <xsl:with-param name="targetNode" select="$targetNode"/>
  871. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  872. <xsl:with-param name="xpath" select="$xpath"/>
  873. <xsl:with-param name="alignment" select="'left'"/>
  874. </xsl:call-template>
  875. </td>
  876. </tr>
  877. </xsl:when>
  878. <xsl:otherwise>
  879. <xsl:call-template name="insertAttribNodeInRow">
  880. <xsl:with-param name="tableId" select="$tableId"/>
  881. <xsl:with-param name="rowId" select="$rowId"/>
  882. <xsl:with-param name="targetNode" select="$targetNode"/>
  883. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  884. <xsl:with-param name="xpath" select="$xpath"/>
  885. <xsl:with-param name="alignment" select="'left'"/>
  886. </xsl:call-template>
  887. </xsl:otherwise>
  888. </xsl:choose>
  889. </xsl:otherwise>
  890. </xsl:choose>
  891. </xsl:template>
  892. <xsl:template name="populateTableRow">
  893. <xsl:param name="tableId"/>
  894. <xsl:param name="rowId"/>
  895. <xsl:param name="domNode"/>
  896. <xsl:param name="schemaNode"/>
  897. <xsl:param name="xpath"/>
  898. <xsl:param name="bRowCheckbox"/>
  899. <xsl:param name="bChecked"/>
  900. <xsl:variable name="nodeName" select="name($domNode)"/>
  901. <xsl:if test="$bRowCheckbox">
  902. <td width="35">
  903. <xsl:variable name="cbName" select="concat($xpath, '.checkbox')"/>
  904. <input type="checkbox" name="{$cbName}" value="1">
  905. <xsl:if test="$bChecked">
  906. <xsl:attribute name="checked">true</xsl:attribute>
  907. </xsl:if>
  908. <xsl:attribute name="onclick">
  909. <xsl:value-of select="concat('ms_onChange(this, ', $apos, $tableId, $apos, ', 0)')"/>
  910. </xsl:attribute>
  911. </input>
  912. </td>
  913. </xsl:if>
  914. <xsl:for-each select="$schemaNode/*[name()!='Buttons' and name()!='script' and not(@break)]">
  915. <xsl:choose>
  916. <xsl:when test="@table">
  917. <xsl:call-template name="addTableRows">
  918. <xsl:with-param name="tableId" select="concat($rowId, '.', name())"/>
  919. <xsl:with-param name="objNode" select="$domNode"/>
  920. <xsl:with-param name="schemaNode" select="."/>
  921. <xsl:with-param name="xpath" select="$rowId"/>
  922. <xsl:with-param name="columnCount" select="1"/>
  923. <xsl:with-param name="showTableCaption" select="0"/>
  924. </xsl:call-template>
  925. </xsl:when>
  926. <xsl:otherwise>
  927. <xsl:call-template name="insertCellInRow">
  928. <xsl:with-param name="tableId" select="$tableId"/>
  929. <xsl:with-param name="rowId" select="$rowId"/>
  930. <xsl:with-param name="targetNode" select="$domNode"/>
  931. <xsl:with-param name="schemaNode" select="."/>
  932. <xsl:with-param name="xpath" select="$rowId"/>
  933. </xsl:call-template>
  934. </xsl:otherwise>
  935. </xsl:choose>
  936. </xsl:for-each>
  937. <xsl:if test="$schemaNode/@overrideRow='after'">
  938. <xsl:apply-templates select="$schemaNode" mode="overrideRow">
  939. <xsl:with-param name="objNode" select="$domNode"/>
  940. <xsl:with-param name="rowId" select="$rowId"/>
  941. <xsl:with-param name="columnHeader" select="0"/>
  942. </xsl:apply-templates>
  943. </xsl:if>
  944. </xsl:template>
  945. <xsl:template name="insertCellInRow">
  946. <xsl:param name="tableId"/>
  947. <xsl:param name="rowId"/>
  948. <xsl:param name="targetNode"/>
  949. <xsl:param name="schemaNode"/>
  950. <xsl:param name="xpath"/>
  951. <xsl:variable name="maxOccurs" select="$schemaNode/@maxOccurs"/>
  952. <xsl:choose>
  953. <xsl:when test="string($maxOccurs)='unbounded'">
  954. <!--create another table that would occupy entire cell of parent table's row-->
  955. <xsl:variable name="xpath2">
  956. <xsl:if test="string($xpath)!=''">
  957. <xsl:value-of select="$xpath"/>
  958. <xsl:text>.</xsl:text>
  959. </xsl:if>
  960. <xsl:value-of select="name($schemaNode)"/>
  961. </xsl:variable>
  962. <td style="padding:0;margin:0">
  963. <xsl:call-template name="createFixedTableWithHeader">
  964. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  965. <xsl:with-param name="targetNode" select="$targetNode"/>
  966. <xsl:with-param name="tableId" select="$xpath2"/>
  967. <xsl:with-param name="xpath" select="$xpath"/>
  968. <xsl:with-param name="width" select="'100%'"/>
  969. </xsl:call-template>
  970. <!--border="0" cellspacing="0"-->
  971. <!--xsl:call-template name="createButtons">
  972. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  973. <xsl:with-param name="targetNode" select="$targetNode"/>
  974. </xsl:call-template-->
  975. </td>
  976. </xsl:when><!--unbounded-->
  977. <xsl:when test="string($maxOccurs)='1'">
  978. <xsl:variable name="name" select="name($schemaNode)"/>
  979. <xsl:variable name="childNode" select="$targetNode/*[name()=$name][1]"/>
  980. <xsl:if test="not($childNode)">
  981. <!--TODO-->
  982. </xsl:if>
  983. <xsl:variable name="xpath3">
  984. <xsl:if test="string($xpath)!=''">
  985. <xsl:value-of select="$xpath"/>
  986. <xsl:text>.</xsl:text>
  987. </xsl:if>
  988. <xsl:value-of select="$name"/>
  989. </xsl:variable>
  990. <xsl:for-each select="$schemaNode/*[name()!='Buttons' and name()!='script']">
  991. <xsl:call-template name="insertCellInRow">
  992. <xsl:with-param name="tableId" select="$tableId"/>
  993. <xsl:with-param name="rowId" select="$rowId"/>
  994. <xsl:with-param name="targetNode" select="$childNode"/>
  995. <xsl:with-param name="schemaNode" select="."/>
  996. <xsl:with-param name="xpath" select="$xpath3"/>
  997. </xsl:call-template>
  998. </xsl:for-each>
  999. </xsl:when>
  1000. <xsl:otherwise><!--attribute or innerText-->
  1001. <xsl:variable name="name" select="name($schemaNode)"/>
  1002. <xsl:variable name="inner" select="$schemaNode/@dataType='innerText'"/>
  1003. <xsl:variable name="childNode"
  1004. select="$targetNode[$inner]|$targetNode/*[not($inner) and name()=$name]"/>
  1005. <xsl:choose>
  1006. <xsl:when test="string($schemaNode/@viewType)!='hidden'">
  1007. <td>
  1008. <xsl:copy-of select="$schemaNode/@width"/>
  1009. <xsl:call-template name="insertAttribNodeInRow">
  1010. <xsl:with-param name="tableId" select="$tableId"/>
  1011. <xsl:with-param name="rowId" select="$rowId"/>
  1012. <xsl:with-param name="targetNode" select="$childNode"/>
  1013. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  1014. <xsl:with-param name="xpath" select="$xpath"/>
  1015. </xsl:call-template>
  1016. </td>
  1017. </xsl:when>
  1018. <xsl:otherwise>
  1019. <xsl:call-template name="insertAttribNodeInRow">
  1020. <xsl:with-param name="tableId" select="$tableId"/>
  1021. <xsl:with-param name="rowId" select="$rowId"/>
  1022. <xsl:with-param name="targetNode" select="$childNode"/>
  1023. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  1024. <xsl:with-param name="xpath" select="$xpath"/>
  1025. </xsl:call-template>
  1026. </xsl:otherwise>
  1027. </xsl:choose>
  1028. </xsl:otherwise>
  1029. </xsl:choose>
  1030. </xsl:template>
  1031. <xsl:template name="insertAttribNodeInRow">
  1032. <xsl:param name="tableId"/>
  1033. <xsl:param name="rowId"/>
  1034. <xsl:param name="targetNode"/>
  1035. <xsl:param name="schemaNode"/>
  1036. <xsl:param name="xpath"/>
  1037. <xsl:param name="alignment"/>
  1038. <xsl:for-each select="$schemaNode">
  1039. <xsl:if test="string(@viewType)!='hidden'">
  1040. <xsl:if test="@overrideCell='before'">
  1041. <xsl:apply-templates select="." mode="overrideCell">
  1042. <xsl:with-param name="objNode" select="$targetNode"/>
  1043. <xsl:with-param name="rowId" select="$rowId"/>
  1044. <xsl:with-param name="columnHeader" select="0"/>
  1045. </xsl:apply-templates>
  1046. </xsl:if>
  1047. <xsl:if test="string(@align)!='' or string($alignment)!=''">
  1048. <xsl:attribute name="style"><!--we need to define style since @align cannot override sort-table's style-->
  1049. <xsl:text>text-align:</xsl:text>
  1050. <xsl:choose>
  1051. <xsl:when test="string(@align)!=''">
  1052. <xsl:value-of select="@align"/>
  1053. </xsl:when>
  1054. <xsl:otherwise>
  1055. <xsl:value-of select="$alignment"/>
  1056. </xsl:otherwise>
  1057. </xsl:choose>
  1058. </xsl:attribute>
  1059. </xsl:if>
  1060. <xsl:copy-of select="@valign"/>
  1061. <xsl:if test="@dataType!='boolean' and @dataType!='file'">
  1062. <xsl:copy-of select="@nowrap|@width"/>
  1063. </xsl:if>
  1064. <xsl:variable name="isStatic"
  1065. select="starts-with(@viewType, 'static') or @viewType='tooltip'"/>
  1066. <xsl:if test="$isStatic">
  1067. <xsl:if test="@span">
  1068. <xsl:text disable-output-escaping="yes">&lt;span id="</xsl:text>
  1069. <xsl:value-of select="concat($xpath, '.', name(), '.span')"/>
  1070. <xsl:text disable-output-escaping="yes">"&gt;</xsl:text>
  1071. </xsl:if>
  1072. <xsl:choose>
  1073. <xsl:when test="@viewType='tooltip'">
  1074. <xsl:variable name="len" select="string-length($targetNode/text())"/>
  1075. <xsl:choose>
  1076. <xsl:when test="$len&lt;8">
  1077. <xsl:value-of select="$targetNode/text()"/>
  1078. </xsl:when>
  1079. <xsl:otherwise>
  1080. <xsl:attribute name="onmouseover">
  1081. <xsl:text>EnterContent('ToolTip', null, '</xsl:text>
  1082. <xsl:value-of select="$targetNode/text()"/>
  1083. <xsl:text>', true; Activate();</xsl:text>
  1084. </xsl:attribute>
  1085. <xsl:attribute name="onmouseout">deActivate()</xsl:attribute>
  1086. <xsl:value-of select="substring(string($targetNode), 1, 4)"/>
  1087. <xsl:text>...</xsl:text>
  1088. </xsl:otherwise>
  1089. </xsl:choose>
  1090. </xsl:when><!--tooltip-->
  1091. <xsl:when test="@dataType='boolean'">
  1092. <xsl:value-of select="$targetNode/text()"/>
  1093. </xsl:when>
  1094. <xsl:when test="string($targetNode)!=''">
  1095. <xsl:choose>
  1096. <xsl:when test="contains(@viewType, ':')">
  1097. <xsl:variable name="options" select="substring-after(@viewType, ':')"/>
  1098. <xsl:call-template name="getIndexedOption">
  1099. <xsl:with-param name="stringOptions" select="$options"/>
  1100. <xsl:with-param name="index" select="number($targetNode)"/>
  1101. </xsl:call-template>
  1102. </xsl:when>
  1103. <xsl:otherwise>
  1104. <xsl:value-of select="$targetNode/text()"/>
  1105. </xsl:otherwise>
  1106. </xsl:choose>
  1107. </xsl:when>
  1108. <xsl:otherwise>&nbsp;</xsl:otherwise>
  1109. </xsl:choose>
  1110. <xsl:if test="@span">
  1111. <xsl:text disable-output-escaping="yes">&lt;/span&gt;</xsl:text>
  1112. </xsl:if>
  1113. </xsl:if><!--$isStatic-->
  1114. </xsl:if>
  1115. <xsl:if test="string(@dataType) != 'none'">
  1116. <xsl:call-template name="createInputControlForNode">
  1117. <xsl:with-param name="tableId" select="$tableId"/>
  1118. <xsl:with-param name="rowId" select="$rowId"/>
  1119. <xsl:with-param name="idPrefix" select="$xpath"/>
  1120. <xsl:with-param name="node" select="$targetNode"/>
  1121. <xsl:with-param name="schemaNode" select="."/>
  1122. <xsl:with-param name="dataType" select="@dataType"/>
  1123. <xsl:with-param name="viewType" select="@viewType"/>
  1124. <xsl:with-param name="columnHeader" select="0"/>
  1125. <xsl:with-param name="multiselect" select="@multiselect='true'"/>
  1126. </xsl:call-template>
  1127. </xsl:if>
  1128. <xsl:if test="@overrideCell='after'">
  1129. <xsl:apply-templates select="." mode="overrideCell">
  1130. <xsl:with-param name="objNode" select="$targetNode"/>
  1131. <xsl:with-param name="rowId" select="$rowId"/>
  1132. <xsl:with-param name="columnHeader" select="0"/>
  1133. </xsl:apply-templates>
  1134. </xsl:if>
  1135. </xsl:for-each>
  1136. </xsl:template>
  1137. <xsl:template name="getIndexedOption">
  1138. <xsl:param name="stringOptions"/>
  1139. <xsl:param name="index"/>
  1140. <xsl:choose>
  1141. <xsl:when test="$index=0">
  1142. <xsl:choose>
  1143. <xsl:when test="contains($stringOptions, '|')">
  1144. <xsl:value-of select="substring-before($stringOptions, '|')"/>
  1145. </xsl:when>
  1146. <xsl:otherwise>
  1147. <xsl:value-of select="$stringOptions"/>
  1148. </xsl:otherwise>
  1149. </xsl:choose>
  1150. </xsl:when>
  1151. <xsl:when test="$index=0">
  1152. <xsl:value-of select="substring-before($stringOptions, '|')"/>
  1153. </xsl:when>
  1154. <xsl:otherwise>
  1155. <xsl:call-template name="getIndexedOption">
  1156. <xsl:with-param name="stringOptions" select="substring-after($stringOptions, '|')"/>
  1157. <xsl:with-param name="index" select="number($index)-1"/>
  1158. </xsl:call-template>
  1159. </xsl:otherwise>
  1160. </xsl:choose>
  1161. </xsl:template>
  1162. <xsl:template name="createInputControlForNode">
  1163. <xsl:param name="tableId"/>
  1164. <xsl:param name="rowId"/>
  1165. <xsl:param name="idPrefix"/>
  1166. <xsl:param name="node"/>
  1167. <xsl:param name="schemaNode"/>
  1168. <xsl:param name="dataType"/>
  1169. <xsl:param name="viewType"/>
  1170. <xsl:param name="multiselect"/>
  1171. <xsl:param name="columnHeader"/>
  1172. <xsl:variable name="id">
  1173. <xsl:if test="string($idPrefix)!=''">
  1174. <xsl:value-of select="$idPrefix"/>
  1175. </xsl:if>
  1176. <xsl:if test="name($schemaNode)!='innerText'">
  1177. <xsl:if test="string($idPrefix)!=''">
  1178. <xsl:text>.</xsl:text>
  1179. </xsl:if>
  1180. <xsl:value-of select="name($schemaNode)"/>
  1181. </xsl:if>
  1182. </xsl:variable>
  1183. <xsl:variable name="value">
  1184. <xsl:if test="not($columnHeader)">
  1185. <xsl:choose>
  1186. <xsl:when test="string($node/text())!=''">
  1187. <xsl:value-of select="$node/text()"/>
  1188. </xsl:when>
  1189. <xsl:otherwise>
  1190. <xsl:value-of select="$schemaNode/@default"/>
  1191. </xsl:otherwise>
  1192. </xsl:choose>
  1193. </xsl:if>
  1194. </xsl:variable>
  1195. <xsl:variable name="type">
  1196. <xsl:choose>
  1197. <xsl:when test="$viewType='hidden'">hidden</xsl:when>
  1198. <xsl:when test="starts-with($viewType, 'static')">hidden</xsl:when>
  1199. <xsl:when test="$viewType='tooltip'">hidden</xsl:when>
  1200. <xsl:when test="$viewType='select'">select-one</xsl:when>
  1201. <xsl:when test="$dataType='boolean'">checkbox</xsl:when>
  1202. <xsl:when test="$viewType='showHideRowBtn'">hidden</xsl:when>
  1203. <xsl:when test="$viewType='url'">hidden</xsl:when>
  1204. <xsl:when test="$dataType='file'">file</xsl:when>
  1205. <xsl:otherwise>text</xsl:otherwise>
  1206. </xsl:choose>
  1207. </xsl:variable>
  1208. <xsl:if test="$columnHeader and $type='hidden'">
  1209. <xsl:message terminate="yes">
  1210. <xsl:text>Multiple selection is not supported for columns with type </xsl:text>
  1211. <xsl:value-of select="$viewType"/>
  1212. </xsl:message>
  1213. </xsl:if>
  1214. <xsl:variable name="inputName">
  1215. <xsl:choose>
  1216. <xsl:when test="$viewType='select'">select</xsl:when>
  1217. <xsl:otherwise>input</xsl:otherwise>
  1218. </xsl:choose>
  1219. </xsl:variable>
  1220. <xsl:variable name="modifiedHandlerName">
  1221. <xsl:choose>
  1222. <xsl:when test="$type='checkbox' or $type='file'">onclick</xsl:when>
  1223. <xsl:when test="$type='hidden'"></xsl:when>
  1224. <xsl:otherwise>onchange</xsl:otherwise>
  1225. </xsl:choose>
  1226. </xsl:variable>
  1227. <xsl:variable name="disabled">
  1228. <xsl:if test="$type!='hidden'">
  1229. <xsl:choose>
  1230. <xsl:when test="string($schemaNode/@disabled)='1'">1</xsl:when>
  1231. <xsl:when test="string($node/@disabled)='1'">1</xsl:when>
  1232. <xsl:otherwise>0</xsl:otherwise>
  1233. </xsl:choose>
  1234. </xsl:if>
  1235. </xsl:variable>
  1236. <xsl:if test="$schemaNode/@override">
  1237. <xsl:apply-templates select="$schemaNode" mode="override">
  1238. <xsl:with-param name="objNode" select="$node"/>
  1239. <xsl:with-param name="rowId" select="$rowId"/>
  1240. <xsl:with-param name="columnHeader" select="$columnHeader"/>
  1241. </xsl:apply-templates>
  1242. </xsl:if>
  1243. <xsl:element name="{$inputName}">
  1244. <xsl:if test="string($type)!=''">
  1245. <xsl:attribute name="type">
  1246. <xsl:value-of select="$type"/>
  1247. </xsl:attribute>
  1248. </xsl:if>
  1249. <xsl:choose>
  1250. <xsl:when test="$columnHeader">
  1251. <xsl:attribute name="id">
  1252. <xsl:value-of select="concat($tableId, '_ms', $schemaNode/@column, '_T_I')"/>
  1253. </xsl:attribute>
  1254. <!--TODO set inputTag and inputType of multiselect-->
  1255. <xsl:attribute name="style">display:none</xsl:attribute>
  1256. <xsl:attribute name="title">
  1257. <xsl:choose>
  1258. <xsl:when test="$type='checkbox'">
  1259. <xsl:text>Check or uncheck all items in this column</xsl:text>
  1260. </xsl:when>
  1261. <xsl:otherwise>
  1262. <xsl:text>Update all items in this column with this value</xsl:text>
  1263. </xsl:otherwise>
  1264. </xsl:choose>
  1265. </xsl:attribute>
  1266. </xsl:when>
  1267. <xsl:otherwise>
  1268. <xsl:attribute name="id">
  1269. <xsl:value-of select="$id"/>
  1270. </xsl:attribute>
  1271. <xsl:attribute name="name">
  1272. <xsl:value-of select="$id"/>
  1273. </xsl:attribute>
  1274. <!--xsl:if test="string(@viewType)!='showHideRowBtn' or string(@dataType)!='none'">
  1275. <xsl:attribute name="name">
  1276. <xsl:value-of select="$id"/>
  1277. </xsl:attribute>
  1278. </xsl:if-->
  1279. <xsl:if test="string($viewType)!='select'">
  1280. <xsl:attribute name="value">
  1281. <xsl:choose>
  1282. <xsl:when test="string($type)='checkbox'">1</xsl:when>
  1283. <xsl:otherwise>
  1284. <xsl:value-of select="$value"/>
  1285. </xsl:otherwise>
  1286. </xsl:choose>
  1287. </xsl:attribute>
  1288. </xsl:if>
  1289. </xsl:otherwise>
  1290. </xsl:choose>
  1291. <xsl:if test="$disabled=1">
  1292. <xsl:attribute name="disabled">true</xsl:attribute>
  1293. </xsl:if>
  1294. <xsl:choose>
  1295. <xsl:when test="$type='checkbox'">
  1296. <xsl:if test="$value='1'">
  1297. <xsl:attribute name="checked">true</xsl:attribute>
  1298. </xsl:if>
  1299. </xsl:when>
  1300. <xsl:when test="$type='text'">
  1301. <xsl:copy-of select="$schemaNode/@size"/>
  1302. </xsl:when>
  1303. </xsl:choose>
  1304. <xsl:if test="string($modifiedHandlerName)!=''">
  1305. <xsl:attribute name="{$modifiedHandlerName}">
  1306. <xsl:text>setModified(); </xsl:text>
  1307. <xsl:if test="$multiselect">
  1308. <xsl:choose>
  1309. <xsl:when test="$columnHeader">ms_setAll</xsl:when>
  1310. <xsl:otherwise>ms_onChange</xsl:otherwise>
  1311. </xsl:choose>
  1312. <xsl:value-of select="concat('(this, ', $apos, $tableId, $apos, ', ', $schemaNode/@column, ');')"/>
  1313. <xsl:if test="$columnHeader"> <!--ms column > 0 -->
  1314. <xsl:text>; this.style.display='none';</xsl:text>
  1315. </xsl:if>
  1316. </xsl:if>
  1317. <xsl:variable name="handlerAttrib"
  1318. select="$schemaNode/@*[name()=$modifiedHandlerName]"/>
  1319. <xsl:if test="not($columnHeader) and $handlerAttrib">
  1320. <xsl:choose>
  1321. <xsl:when test="$node">
  1322. <xsl:call-template name="expand_embedded_xpaths">
  1323. <xsl:with-param name="str" select="$handlerAttrib"/>
  1324. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  1325. <xsl:with-param name="node" select="$node"/>
  1326. </xsl:call-template>
  1327. </xsl:when>
  1328. <xsl:otherwise>
  1329. <xsl:value-of select="$handlerAttrib"/>
  1330. </xsl:otherwise>
  1331. </xsl:choose>
  1332. </xsl:if>
  1333. </xsl:attribute>
  1334. </xsl:if><!--$modifiedHandlerName-->
  1335. <xsl:if test="$type='select-one'">
  1336. <xsl:call-template name="addSelectControlOptions">
  1337. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  1338. <xsl:with-param name="node" select="$node[not($schemaNode/@xpath)] | $objRootNode[$schemaNode/@xpath='/']/*[name()=name($schemaNode)]"/>
  1339. <xsl:with-param name="value" select="$value"/>
  1340. </xsl:call-template>
  1341. </xsl:if>
  1342. </xsl:element>
  1343. <xsl:choose>
  1344. <xsl:when test="$columnHeader">
  1345. <xsl:if test="$multiselect">
  1346. <xsl:variable name="ms_onchange_item" select="string($schemaNode/@ms_onchange_item)"/>
  1347. <xsl:variable name="ms_onchange_item_handler">
  1348. <xsl:choose>
  1349. <xsl:when test="$ms_onchange_item!=''"><xsl:value-of select="$ms_onchange_item"/></xsl:when>
  1350. <xsl:otherwise>null</xsl:otherwise>
  1351. </xsl:choose>
  1352. </xsl:variable>
  1353. <script type="text/javascript">
  1354. <xsl:variable name="msId" select="concat($tableId, '_ms', string(@column), '_T')"/>
  1355. <xsl:value-of select="concat('var input = document.getElementById(', $apos, $msId, '_I', $apos, ');')"/>
  1356. <xsl:value-of select="concat('ms_create(', $apos, $tableId, $apos, ', onColumnCheck, ', $ms_onchange_item_handler, ', ', @column, ', input.tagName, input.type);')"/>
  1357. </script>
  1358. </xsl:if>
  1359. </xsl:when>
  1360. <xsl:otherwise>
  1361. <xsl:choose>
  1362. <xsl:when test="string(@viewType)='showHideRowBtn'">
  1363. <input type="button" id="{$id}.btn" value="Show">
  1364. <xsl:choose>
  1365. <xsl:when test="string($node/text())!=''">
  1366. <xsl:attribute name="onclick">
  1367. <xsl:value-of select="concat('onShowHideRow(', $apos, $tableId, $apos, ',', $apos, $rowId, $apos, ',', 'this)')"/>
  1368. </xsl:attribute>
  1369. </xsl:when>
  1370. <xsl:otherwise>
  1371. <xsl:attribute name="disabled">true</xsl:attribute>
  1372. </xsl:otherwise>
  1373. </xsl:choose>
  1374. </input>
  1375. </xsl:when>
  1376. <xsl:when test="$viewType='url'">
  1377. <a id="{$id}.url">
  1378. <xsl:copy-of select="$schemaNode/@onclick|$schemaNode/@href"/>
  1379. <xsl:value-of select="$value"/>
  1380. </a>
  1381. </xsl:when>
  1382. </xsl:choose>
  1383. </xsl:otherwise>
  1384. </xsl:choose>
  1385. </xsl:template>
  1386. <xsl:template name="addSelectControlOptions">
  1387. <xsl:param name="schemaNode"/>
  1388. <xsl:param name="node"/>
  1389. <xsl:param name="value"/>
  1390. <xsl:if test="$schemaNode/@source='object' and not($node)">
  1391. <xsl:attribute name="disabled">true</xsl:attribute>
  1392. </xsl:if>
  1393. <xsl:if test="$schemaNode/@addEmpty='true'">
  1394. <option value="">
  1395. <xsl:if test="$value and string($value)=''">
  1396. <xsl:attribute name="selected">true</xsl:attribute>
  1397. </xsl:if>
  1398. </option>
  1399. </xsl:if>
  1400. <xsl:choose>
  1401. <xsl:when test="$schemaNode/@source='object'">
  1402. <!--optionTag defines tag name of child that defines an option-->
  1403. <xsl:variable name="optionTag">
  1404. <xsl:choose>
  1405. <xsl:when test="$schemaNode/@option">
  1406. <xsl:value-of select="$schemaNode/@option"/>
  1407. </xsl:when>
  1408. <xsl:otherwise>option</xsl:otherwise>
  1409. </xsl:choose>
  1410. </xsl:variable>
  1411. <!--
  1412. '@text', '@value' and '@selected' attributes of schemaNode
  1413. hold the needed tag names which are used to populate the drop down list
  1414. these are supposed to be child nodes of option node in object hierarchy
  1415. for instance, the following schema node definition creates a select object
  1416. from the object node below and selects second item:
  1417. <NameServices caption="Name Service" viewType="select" source="object"
  1418. option="NameService" text="Name" value="Value" selected="Selected"/>
  1419. object node:
  1420. <NameServices>
  1421. <NameService>
  1422. <Name>ns1</Name>
  1423. <Value>val1</Value>
  1424. </NameService>
  1425. <NameService>
  1426. <Name>ns2</Name>
  1427. <Value>val2</Value>
  1428. <Selected>true</Selected>
  1429. </NameService>
  1430. </NameServices>
  1431. -->
  1432. <xsl:variable name="textTag" select="$schemaNode/@text"/>
  1433. <xsl:variable name="valueTag" select="$schemaNode/@value"/>
  1434. <xsl:variable name="selectedTag" select="$schemaNode/@selected"/>
  1435. <xsl:choose>
  1436. <xsl:when test="$node">
  1437. <xsl:for-each select="$node/*[name()=$optionTag]">
  1438. <xsl:variable name="option" select="."/>
  1439. <xsl:variable name="val" select="*[name()=$valueTag][1]/text()"/>
  1440. <option value="{$val}">
  1441. <xsl:variable name="selected" select="*[name()=$selectedTag][1]"/>
  1442. <xsl:if test="$selected=1 or $val=string($value)">
  1443. <xsl:attribute name="selected">true</xsl:attribute>
  1444. </xsl:if>
  1445. <xsl:value-of select="*[name()=$textTag][1]/text()"/>
  1446. </option>
  1447. </xsl:for-each>
  1448. </xsl:when><!--$node-->
  1449. <xsl:otherwise><!--$node is null-->
  1450. <option value="">-undefined-</option>
  1451. </xsl:otherwise>
  1452. </xsl:choose>
  1453. </xsl:when><!--$schemaNode/@source='object'-->
  1454. <xsl:otherwise><!--$schemaNode/@source!='object'-->
  1455. <xsl:for-each select="$schemaNode/option">
  1456. <option value="{@value}">
  1457. <xsl:if test="$value and string($value)=string(@value)">
  1458. <xsl:attribute name="selected">true</xsl:attribute>
  1459. </xsl:if>
  1460. <xsl:value-of select="text()"/>
  1461. </option>
  1462. </xsl:for-each>
  1463. </xsl:otherwise>
  1464. </xsl:choose>
  1465. </xsl:template>
  1466. <xsl:template name="expand_embedded_xpaths">
  1467. <xsl:param name="str" select="$handlerAttrib"/>
  1468. <xsl:param name="schemaNode" select="$schemaNode"/>
  1469. <xsl:param name="node" select="$node"/>
  1470. <xsl:choose>
  1471. <xsl:when test="contains($str, '{')">
  1472. <xsl:variable name="prefix" select="substring-before($str, '{')"/>
  1473. <xsl:variable name="suffix" select="substring-after($str, '{')"/>
  1474. <xsl:variable name="embraced" select="substring-before($suffix, '}')"/>
  1475. <xsl:variable name="replacement">
  1476. <xsl:choose>
  1477. <xsl:when test="$pattern='.'"><xsl:value-of select="$node/text()"/></xsl:when>
  1478. <xsl:otherwise><xsl:value-of select="$node/*[name()=$embraced]"/></xsl:otherwise>
  1479. </xsl:choose>
  1480. </xsl:variable>
  1481. <xsl:value-of select="$prefix"/>
  1482. <xsl:value-of select="$replacement"/>
  1483. <xsl:call-template name="expand_embedded_xpaths">
  1484. <xsl:with-param name="str" select="substring-after($suffix, '}')"/>
  1485. <xsl:with-param name="schemaNode" select="$schemaNode"/>
  1486. <xsl:with-param name="node" select="$node"/>
  1487. </xsl:call-template>
  1488. </xsl:when>
  1489. <xsl:otherwise>
  1490. <xsl:value-of select="$str"/>
  1491. </xsl:otherwise>
  1492. </xsl:choose>
  1493. </xsl:template>
  1494. <xsl:template match="*|@*" mode="copy">
  1495. <xsl:copy>
  1496. <xsl:apply-templates select="*|@*|text()" mode="copy"/>
  1497. </xsl:copy>
  1498. </xsl:template>
  1499. <xsl:template match="text()" mode="copy">
  1500. <xsl:copy-of select="normalize-space(.)"/>
  1501. </xsl:template>
  1502. </xsl:stylesheet>