Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.17 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
  3. <xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="no" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="xhtml1-transitional.dtd" indent="no" media-type="text/html"/>
  4.  
  5. <xsl:variable name="navigation_document" select="'navigation.xml'"/>
  6. <xsl:variable name="blocks_document" select="'blocks2.xml'"/>
  7. <xsl:variable name="currentsection" select="/main/idref"/>
  8.  
  9. <!--*************************************************-->
  10. <!--************************main**********************-->
  11. <!--*************************************************-->
  12. <xsl:template match="main">
  13. <html>
  14. <xsl:call-template name="site_header"/>
  15. <xsl:call-template name="display_site"/>
  16. </html>
  17. </xsl:template>
  18. <!--*************************************************-->
  19.  
  20. <!--*************************************************-->
  21. <!--************************site_header************-->
  22. <!--*************************************************-->
  23. <xsl:template name="site_header">
  24. <head>
  25. <xsl:call-template name="page_title"/>
  26. <xsl:call-template name="css_insert"/>
  27. </head>
  28. </xsl:template>
  29. <!--*************************************************-->
  30.  
  31. <!--*************************************************-->
  32. <!--************************page_title************-->
  33. <!--*************************************************-->
  34. <xsl:template name="page_title">
  35. <title>
  36. <xsl:value-of select="/main/pagetitle"/>
  37. </title>
  38. </xsl:template>
  39. <!--*************************************************-->
  40.  
  41. <!--*************************************************-->
  42. <!--************************css_insert************-->
  43. <!--*************************************************-->
  44. <xsl:template name="css_insert">
  45. <link rel="stylesheet" type="text/css" media="screen" href="examplesite1.css"/>
  46. </xsl:template>
  47. <!--*************************************************-->
  48.  
  49.  
  50.  
  51. <!--*************************************************-->
  52. <!--************************display_site************-->
  53. <!--*************************************************-->
  54. <xsl:template name="display_site">
  55. <body>
  56. <table class="formatter" cellspacing="0" cellpadding="0" border="0">
  57. <tr>
  58. <td class="banner">
  59. <xsl:call-template name="banner"/>
  60. </td>
  61. </tr>
  62. <tr>
  63. <td class="horizontaltoolbar">
  64. <xsl:call-template name="horizontaltoolbar"/>
  65. </td>
  66. </tr>
  67. <tr>
  68. <td>
  69. <table class="formatter" cellspacing="0" cellpadding="0" border="0">
  70. <tr>
  71. <td class="verticletoolbar">
  72. <xsl:call-template name="verticletoolbar"/>
  73. </td>
  74. <td class="maincontent">
  75. <xsl:call-template name="maincontent"/>
  76. </td>
  77. <td class="flagbar">
  78. <xsl:call-template name="flagbar"/>
  79. </td>
  80. </tr>
  81. </table>
  82. </td>
  83. </tr>
  84. <tr>
  85. <td class="footer">
  86. <xsl:call-template name="footer"/>
  87. </td>
  88. </tr>
  89. </table>
  90. </body>
  91. </xsl:template>
  92. <!--*************************************************-->
  93.  
  94. <!--*************************************************-->
  95. <!--************************flagbar******************-->
  96. <!--*************************************************-->
  97. <xsl:template name="flagbar">
  98. <div class="flagbar">
  99. </div>
  100. </xsl:template>
  101. <!--*************************************************-->
  102.  
  103. <!--*************************************************-->
  104. <!--************************banner*****************-->
  105. <!--*************************************************-->
  106. <xsl:template name="banner">
  107. <div class="banner">
  108. <xsl:call-template name="handlepagefragment">
  109. <xsl:with-param name="blockid">sample</xsl:with-param>
  110. </xsl:call-template>
  111. </div>
  112. </xsl:template>
  113. <!--*************************************************-->
  114.  
  115. <!--*************************************************-->
  116. <!--************************horizontaltoolbar******-->
  117. <!--*************************************************-->
  118. <xsl:template name="horizontaltoolbar">
  119. <div class="horizontaltoolbar">
  120. <xsl:for-each select="document($navigation_document)">
  121. <table cellpadding="0" cellspacing="0">
  122. <tr>
  123. <xsl:for-each select="navigation/menu/menu">
  124. <xsl:call-template name="htbitem"/>
  125. </xsl:for-each>
  126. </tr>
  127. </table>
  128. </xsl:for-each>
  129. </div>
  130. </xsl:template>
  131. <!--*************************************************-->
  132.  
  133.  
  134. <!--*************************************************-->
  135. <!--************************htbitem*****************-->
  136. <!--*************************************************-->
  137. <xsl:template name="htbitem">
  138. <td >
  139. <xsl:call-template name="htbclass"/>
  140. <a>
  141. <xsl:call-template name="htbclass"/>
  142. <xsl:call-template name="menuurl"/>
  143. <xsl:value-of select="title"/>
  144. </a>
  145. </td>
  146. </xsl:template>
  147. <!--*************************************************-->
  148.  
  149. <xsl:template name="htbclass">
  150. <xsl:attribute name="class">
  151. <xsl:choose>
  152. <xsl:when test="descendant-or-self::*[id=$currentsection]">
  153. selectedhtbitem
  154. </xsl:when>
  155. <xsl:otherwise>
  156. htbitem
  157. </xsl:otherwise>
  158. </xsl:choose>
  159. </xsl:attribute>
  160. </xsl:template>
  161.  
  162. <!--*************************************************-->
  163. <!--************************menuurl******-->
  164. <!--*************************************************-->
  165. <xsl:template name="menuurl">
  166. <xsl:attribute name="href">
  167. <xsl:choose>
  168. <xsl:when test="count(idref)>0">
  169. <xsl:call-template name="lookupmenu">
  170. <xsl:with-param name="menuid">
  171. <xsl:value-of select="idref"/>
  172. </xsl:with-param>
  173. </xsl:call-template>
  174. </xsl:when>
  175. <xsl:when test="url">
  176. <xsl:value-of select="url"/>
  177. </xsl:when>
  178. <xsl:when test="count(menu)>0">
  179. <xsl:for-each select="menu">
  180. <xsl:if test="position()=1">
  181. <xsl:call-template name="url"/>
  182. </xsl:if>
  183. </xsl:for-each>
  184. </xsl:when>
  185. </xsl:choose>
  186. </xsl:attribute>
  187. </xsl:template>
  188. <!--*************************************************-->
  189.  
  190.  
  191. <!--*************************************************-->
  192. <!--************************lookupmenu******-->
  193. <!--*************************************************-->
  194. <xsl:template name="lookupmenu">
  195. <xsl:param name="menuid"/>lookup
  196. <xsl:for-each select="document($navigation_document)//menu">
  197. <xsl:if test="id=$menuid">
  198. <xsl:call-template name="url"/>
  199. </xsl:if>
  200. </xsl:for-each>
  201. </xsl:template>
  202. <!--*************************************************-->
  203.  
  204.  
  205.  
  206. <!--*************************************************-->
  207. <!--************************url******-->
  208. <!--*************************************************-->
  209. <xsl:template name="url">
  210. <xsl:choose>
  211. <xsl:when test="url">
  212. <xsl:value-of select="url"/>
  213. </xsl:when>
  214. <xsl:otherwise>
  215. <xsl:for-each select="menu">
  216. <xsl:if test="position()=1">
  217. <xsl:call-template name="url"/>
  218. </xsl:if>
  219. </xsl:for-each>
  220. </xsl:otherwise>
  221. </xsl:choose>
  222. </xsl:template>
  223. <!--*************************************************-->
  224.  
  225.  
  226. <!--*************************************************-->
  227. <!--************************maincontent*****************-->
  228. <!--*************************************************-->
  229. <xsl:template name="maincontent">
  230. <div class="maincontent">
  231. <xsl:apply-templates select="/main/content"/>
  232. </div>
  233. </xsl:template>
  234. <!--*************************************************-->
  235.  
  236. <!--*************************************************-->
  237. <!--************************verticletoolbar************-->
  238. <!--*************************************************-->
  239. <xsl:template name="verticletoolbar">
  240. <xsl:for-each select="document($navigation_document)">
  241. <xsl:for-each select="navigation/menu/menu">
  242. <xsl:choose>
  243. <xsl:when test="descendant-or-self::*[id=$currentsection]">
  244. <xsl:call-template name="rendervtb"/>
  245. </xsl:when>
  246. </xsl:choose>
  247. </xsl:for-each>
  248. </xsl:for-each>
  249. </xsl:template>
  250. <!--*************************************************-->
  251.  
  252. <!--*************************************************-->
  253. <!--************************rendervtb************-->
  254. <!--*************************************************-->
  255. <xsl:template name="rendervtb">
  256. <div class="verticletoolbar">
  257. <table cellpadding="0" cellspacing="0">
  258. <xsl:for-each select="menu">
  259. <tr>
  260. <td >
  261. <xsl:call-template name="vtbclass"/>
  262. <a>
  263. <xsl:call-template name="vtbclass"/>
  264. <xsl:call-template name="menuurl"/>
  265. <xsl:value-of select="title"/>
  266. </a>
  267. </td>
  268. </tr>
  269. </xsl:for-each>
  270. </table>
  271. </div>
  272. </xsl:template>
  273. <!--*************************************************-->
  274.  
  275. <xsl:template name="vtbclass">
  276. <xsl:attribute name="class">
  277. <xsl:choose>
  278. <xsl:when test="descendant-or-self::*[id=$currentsection]">
  279. selectedvtbitem
  280. </xsl:when>
  281. <xsl:otherwise>
  282. vtbitem
  283. </xsl:otherwise>
  284. </xsl:choose>
  285. </xsl:attribute>
  286. </xsl:template>
  287.  
  288.  
  289.  
  290.  
  291. <!--*************************************************-->
  292. <!--************************footer************-->
  293. <!--*************************************************-->
  294. <xsl:template name="footer">
  295. <div class="footer">
  296. </div>
  297. </xsl:template>
  298. <!--*************************************************-->
  299.  
  300. <!--*************************************************-->
  301. <!--************************pagefragment************-->
  302. <!--*************************************************-->
  303. <xsl:template match="pagefragment">
  304. <xsl:choose>
  305. <xsl:when test="count(@idref)>0">
  306. <xsl:call-template name="handlepagefragment">
  307. <xsl:with-param name="blockid" select="@idref"/>
  308. </xsl:call-template>
  309. </xsl:when>
  310. <xsl:otherwise>
  311. <div style="fragment">
  312. <xsl:apply-templates select="*"/>
  313. </div>
  314. </xsl:otherwise>
  315. </xsl:choose>
  316. </xsl:template>
  317. <!--*************************************************-->
  318.  
  319. <!--*************************************************-->
  320. <!--************************handlepagefragment************-->
  321. <!--*************************************************-->
  322. <xsl:template name="handlepagefragment">
  323. <xsl:param name="blockid"/>
  324. <xsl:for-each select="document('blocks.xml')">
  325. <xsl:for-each select="//block_instance">
  326. <xsl:choose>
  327. <xsl:when test="id=$blockid">
  328. <xsl:apply-templates select="pagefragment"/>
  329. </xsl:when>
  330. </xsl:choose>
  331. </xsl:for-each>
  332. </xsl:for-each>
  333. </xsl:template>
  334. <!--*************************************************-->
  335.  
  336.  
  337. <!--*************************************************-->
  338. <!--************************table************-->
  339. <!--*************************************************-->
  340. <xsl:template match="table">
  341. <table border="0" style="width:100%;" cellspacing="0" cellpadding="0">
  342. <xsl:for-each select="tr">
  343. <tr>
  344. <xsl:for-each select="td">
  345. <td>
  346. <xsl:if test="count(@style)>0"><xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute></xsl:if>
  347. <xsl:apply-templates/>
  348. </td>
  349. </xsl:for-each>
  350. </tr>
  351. </xsl:for-each>
  352. </table>
  353. <br/>
  354. </xsl:template>
  355. <!--*************************************************-->
  356.  
  357. <!--*************************************************-->
  358. <!--************************list************-->
  359. <!--*************************************************-->
  360. <xsl:template match="list">
  361. <br/>
  362. <table border="0" style="width:100%;" cellspacing="0" cellpadding="0">
  363. <xsl:for-each select="listitem">
  364. <tr>
  365. <td>
  366. <xsl:apply-templates/>
  367. </td>
  368. </tr>
  369. <tr>
  370. <td class="listseperator">
  371. <img src="images/blank.gif" alt="." class="listseperator"/>
  372. </td>
  373. </tr>
  374. </xsl:for-each>
  375. </table>
  376. </xsl:template>
  377. <!--*************************************************-->
  378.  
  379. <!--*************************************************-->
  380. <!--************************header************-->
  381. <!--*************************************************-->
  382. <xsl:template match="header">
  383. <span class="pageheader">
  384. <xsl:apply-templates/>
  385. </span>
  386. </xsl:template>
  387. <!--*************************************************-->
  388.  
  389. <!--*************************************************-->
  390. <!--************************img************-->
  391. <!--*************************************************-->
  392. <xsl:template match="img">
  393. <img alt="">
  394. <xsl:attribute name="src">
  395. <xsl:value-of select="@src"/>
  396. </xsl:attribute>
  397. </img>
  398. </xsl:template>
  399. <!--*************************************************-->
  400.  
  401. <!--*************************************************-->
  402. <!--************************para************-->
  403. <!--*************************************************-->
  404. <xsl:template match="para">
  405. <p>
  406. <xsl:apply-templates/>
  407. </p>
  408. </xsl:template>
  409. <!--*************************************************-->
  410.  
  411. <!--*************************************************-->
  412. <!--************************br************-->
  413. <!--*************************************************-->
  414. <xsl:template match="br">
  415. <br/>
  416. </xsl:template>
  417. <!--*************************************************-->
  418.  
  419. <!--*************************************************-->
  420. <!--************************strong************-->
  421. <!--*************************************************-->
  422. <xsl:template match="bold">
  423. <b>
  424. <xsl:apply-templates/>
  425. </b>
  426. </xsl:template>
  427. <!--*************************************************-->
  428.  
  429. <!--*************************************************-->
  430. <!--************************link************-->
  431. <!--*************************************************-->
  432. <xsl:template match="link">
  433. <a>
  434. <xsl:choose>
  435. <xsl:when test="idref">
  436. <xsl:call-template name="link_url">
  437. <xsl:with-param name="linkid"><xsl:value-of select="idref"/></xsl:with-param>
  438. </xsl:call-template>
  439. </xsl:when>
  440. <xsl:otherwise>
  441. <xsl:attribute name="href"><xsl:value-of select="url"/></xsl:attribute>
  442. </xsl:otherwise>
  443. </xsl:choose>
  444. <xsl:if test="count(@target)>0">
  445. <xsl:attribute name="target">
  446. <xsl:value-of select="@target"/>
  447. </xsl:attribute>
  448. </xsl:if>
  449. <xsl:apply-templates select="bold | br | img | span| text() "/>
  450. </a>
  451. </xsl:template>
  452. <!--*************************************************-->
  453.  
  454.  
  455. <xsl:template name="link_url">
  456. <xsl:param name="linkid"/>
  457. <xsl:for-each select="document($navigation_document)//menu">
  458. <xsl:if test="$linkid=id">
  459. <xsl:attribute name="href">
  460. <xsl:call-template name="menu_url"/>
  461. </xsl:attribute>
  462. </xsl:if>
  463. </xsl:for-each>
  464. </xsl:template>
  465.  
  466. <xsl:template name="menu_url">
  467. <xsl:choose>
  468. <xsl:when test="count(idref)>0">
  469. <xsl:call-template name="menu_ref_url">
  470. <xsl:with-param name="menu_id">
  471. <xsl:value-of select="idref"/>
  472. </xsl:with-param>
  473. </xsl:call-template>
  474. </xsl:when>
  475. <xsl:otherwise>
  476. <xsl:choose>
  477. <xsl:when test="url">
  478. <xsl:value-of select="url"/>
  479. </xsl:when>
  480. <xsl:when test="menu[1]/url">
  481. <xsl:value-of select="menu[1]/url"/>
  482. </xsl:when>
  483. <xsl:when test="menu[1]/menu[1]/url">
  484. <xsl:value-of select="menu[1]/menu[1]/url"/>
  485. </xsl:when>
  486. <xsl:when test="menu[1]/menu[1]/menu[1]/url">
  487. <xsl:value-of select="menu[1]/menu[1]/menu[1]/url"/>
  488. </xsl:when>
  489. <xsl:when test="menu[1]/menu[1]/menu[1]/menu[1]/url">
  490. <xsl:value-of select="menu[1]/menu[1]/menu[1]/menu[1]/url"/>
  491. </xsl:when>
  492. </xsl:choose>
  493. </xsl:otherwise>
  494. </xsl:choose>
  495. </xsl:template>
  496.  
  497.  
  498.  
  499.  
  500. <xsl:template name="menu_ref_url">
  501. <xsl:param name="menu_id"/>
  502. <xsl:for-each select="document($navigation_document)//menu">
  503. <xsl:if test="id=$menu_id">
  504. <xsl:choose>
  505. <xsl:when test="idref">
  506. <xsl:call-template name="menu_ref_url">
  507. <xsl:with-param name="menu_id">
  508. <xsl:value-of select="idref"/>
  509. </xsl:with-param>
  510. </xsl:call-template>
  511. </xsl:when>
  512. <xsl:when test="idref">
  513. <xsl:call-template name="menu_ref_url">
  514. <xsl:with-param name="menu_id">
  515. <xsl:value-of select="idref"/>
  516. </xsl:with-param>
  517. </xsl:call-template>
  518. </xsl:when>
  519. <xsl:when test="url">
  520. <xsl:value-of select="url"/>
  521. </xsl:when>
  522. <xsl:when test="menu[1]/url">
  523. <xsl:value-of select="menu[1]/url"/>
  524. </xsl:when>
  525. <xsl:when test="menu[1]/menu[1]/url">
  526. <xsl:value-of select="menu[1]/menu[1]/url"/>
  527. </xsl:when>
  528. <xsl:when test="menu[1]/menu[1]/menu[1]/url">
  529. <xsl:value-of select="menu[1]/menu[1]/menu[1]/url"/>
  530. </xsl:when>
  531. <xsl:when test="menu[1]/menu[1]/menu[1]/menu[1]/url">
  532. <xsl:value-of select="menu[1]/menu[1]/menu[1]/menu[1]/url"/>
  533. </xsl:when>
  534. </xsl:choose>
  535. </xsl:if>
  536. </xsl:for-each>
  537. </xsl:template>
  538.  
  539.  
  540.  
  541. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement