Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

testcase2fo.xsl 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <!-- $Id$ -->
  17. <!-- This stylesheet extracts the FO part from the testcase so it can be passed to FOP for layout. -->
  18. <!--
  19. Variable substitution:
  20. For any attribute value that starts with a "##" the stylesheet looks for an element with the variable
  21. name under /testcase/variables, ex. "##img" looks for /testcase/variables/img and uses its element
  22. value as subsitution value.
  23. -->
  24. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
  25. <xsl:template match="testcase">
  26. <xsl:apply-templates select="fo/*" mode="copy"/>
  27. </xsl:template>
  28. <xsl:template match="node()" mode="copy">
  29. <xsl:copy>
  30. <xsl:apply-templates select="@*|node()" mode="copy"/>
  31. </xsl:copy>
  32. </xsl:template>
  33. <xsl:template match="@*" mode="copy">
  34. <xsl:choose>
  35. <xsl:when test="starts-with(., '##')">
  36. <!-- variable substitution -->
  37. <xsl:variable name="nodename" select="name()"/>
  38. <xsl:variable name="varname" select="substring(., 3)"/>
  39. <xsl:choose>
  40. <xsl:when test="boolean(//variables/child::*[local-name() = $varname])">
  41. <xsl:attribute name="{name(.)}">
  42. <xsl:value-of select="//variables/child::*[local-name() = $varname]"/>
  43. </xsl:attribute>
  44. </xsl:when>
  45. <xsl:otherwise>
  46. <!-- if variable isn't defined, just copy -->
  47. <xsl:copy-of select="." />
  48. </xsl:otherwise>
  49. </xsl:choose>
  50. </xsl:when>
  51. <xsl:otherwise>
  52. <xsl:copy-of select="." />
  53. </xsl:otherwise>
  54. </xsl:choose>
  55. </xsl:template>
  56. </xsl:stylesheet>