home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / building / xmlspy / xmlspyentcomplete5.exe / Data1.cab / _B1C62BDAF41642BA82FD4AF2657135BF < prev    next >
Encoding:
Extensible Markup Language  |  2002-08-26  |  10.2 KB  |  239 lines

  1. <xsl:stylesheet version="1.0" 
  2.                 exclude-result-prefixes="msxsl local doc" 
  3.                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  4.                 xmlns:doc="urn:schemas-uspto-gov:document"
  5.                 xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
  6.                 xmlns:local="#local-functions" 
  7.                 extension-element-prefixes="msxsl local">
  8.  
  9. <doc:summary doc:public="yes" >
  10.     <doc:title>Component stylesheet for figures</doc:title>
  11.     <doc:filename>figures-pap.xsl</doc:filename>
  12.     <doc:version>1.0</doc:version>
  13.     <doc:doctype>numerous</doc:doctype>
  14.     <doc:doctype-date>N/A</doc:doctype-date>
  15.     <doc:dateCreated>2001-01-26</doc:dateCreated>
  16.     <doc:lastModified>2001-02-16</doc:lastModified>
  17.     <doc:description>
  18.        Template rules for embedding TIFFs from <image> and <figure> elements
  19.        into an HTML browser.
  20.       <pre style="font-face:arial; font-size:10pt;">
  21.        Notes: 
  22.        sets width & height of embedded plug-in to width & height         
  23.        attributes of image if present; otherwise sets 800 X 600        
  24.     
  25.        preset to "best" fit; fits entire image to width & height      
  26.                                                                        
  27.        NOTE:  width & height are plug-in, not image!                  
  28.  
  29.        96 pixels per inch on Windows screens using Small Icons/fonts; 
  30.        72 pixels per inch on Windows screens using Large Icons/fonts; 
  31.        use 84 to allow for header and footer                          
  32.                                                                    
  33.        300 pixels per inch for USPTO scans           
  34.        </pre>               
  35.        The specification requires extension scripting to get information about the <image>s and <artwork>s.
  36.        See "GENERAL NOTES" in README.txt.
  37.     </doc:description>
  38. </doc:summary>
  39.  
  40.  
  41. <!--
  42. *********************************************************************
  43. * John Dunning: 2001-01-26                                          *
  44. * Component file for image viewing: <artwork>, <image>, <figure>    *
  45. *                                                                   *
  46. * This performs evaluations to test whether the image is a .tiff    *
  47. *   or a .jpg and handles each accordingly                          *
  48. *                                                                   *
  49. * Tests width of image; if smaller than 1.5 inches, displays inline *
  50. *                                                                   *
  51. * sets width & height of embedded plug-in to width & height         *
  52. *   attributes of image if present; otherwise sets 800 X 600        *
  53. *                                                                   *
  54. *    preset to "best" fit; fits entire image to width & height      *
  55. *                                                                   *
  56. *    NOTE:  width & height are plug-in, not image!                  *
  57. *                                                                   *
  58. *    96 pixels per inch on Windows screens using Small Icons/fonts; *
  59. *    72 pixels per inch on Windows screens using Large Icons/fonts; *
  60. *    use 84 to allow for header and footer                          *
  61. *                                                                   *
  62. *    300 pixels per inch for USPTO scans                            *
  63. *********************************************************************
  64. -->
  65.  
  66.     <xsl:template match="artwork">
  67.         <xsl:call-template name="tiff_embedder"/>
  68.     </xsl:template>
  69.  
  70.     <xsl:template match="figure">
  71.         <div class="break_before">
  72.              <xsl:apply-templates />
  73.         </div>
  74.     </xsl:template>
  75.  
  76.     <xsl:template match="drawing-reference-character">
  77.         <xsl:apply-templates />
  78.     </xsl:template>
  79.     
  80.     <xsl:template match="image" name="tiff_embedder" doc:public="yes" doc:description="performs a series of tests; 1) tests whether its a TIFF or JPG; JPG is wrapped in <img> HTML tags, 
  81.     TIFFs in <embed> HTML tags; 2) if image height is greater than 1 inch, it breaks the line;
  82.     3) if no height/width attributes are present, sets tiff viewer to 800X600">
  83.             <xsl:choose>
  84.                   <xsl:when test="local:tagit(.)='1'"><!-- its a TIFF -->
  85.                     <!-- if image is larger than 1 inch, line break_before -->
  86.                      <xsl:if test="local:chooseDiv(.)='0'">
  87.                        <div>
  88.                           <embed toolbar="off" fit="best" align="top">
  89.                              <xsl:choose>
  90.                                 <xsl:when test="@height">                                        
  91.                                     <xsl:attribute name="height">
  92.                                          <xsl:value-of select="local:getHeight(.)"/>
  93.                                     </xsl:attribute>
  94.                                  </xsl:when>
  95.                                  <xsl:otherwise>
  96.                                     <xsl:attribute name="height">800</xsl:attribute>
  97.                                  </xsl:otherwise>
  98.                               </xsl:choose>
  99.                               <xsl:choose>
  100.                                  <xsl:when test="@width">
  101.                                     <xsl:attribute name="width">
  102.                                         <xsl:value-of select="local:getWidth(.)"/>
  103.                                      </xsl:attribute>
  104.                                  </xsl:when>
  105.                                  <xsl:otherwise>
  106.                                     <xsl:attribute name="width">600</xsl:attribute>
  107.                                  </xsl:otherwise>
  108.                                </xsl:choose>
  109.                                 <xsl:attribute name="src">
  110.                                      <xsl:value-of select="local:LookupEntity(.)"/>
  111.                                 </xsl:attribute>
  112.                            </embed>
  113.                         </div>
  114.                     </xsl:if>
  115.                     <!-- otherwise, image is inline (less than 1 inch high) -->
  116.                    <xsl:if test="local:chooseDiv(.)='1'">
  117.                         <embed toolbar="off" fit="best" align="top">
  118.                            <xsl:choose>
  119.                                <xsl:when test="@height">                                        
  120.                                    <xsl:attribute name="height">
  121.                                       <xsl:value-of select="round(local:getHeight(.))"/>
  122.                                    </xsl:attribute>
  123.                                 </xsl:when>
  124.                                 <xsl:otherwise>
  125.                                     <xsl:attribute name="height">800</xsl:attribute>
  126.                                 </xsl:otherwise>
  127.                            </xsl:choose>
  128.                            <xsl:choose>
  129.                                 <xsl:when test="@width">
  130.                                     <xsl:attribute name="width">
  131.                                       <xsl:value-of select="round(local:getWidth(.))"/>
  132.                                      </xsl:attribute>
  133.                                  </xsl:when>
  134.                                  <xsl:otherwise>
  135.                                      <xsl:attribute name="width">600</xsl:attribute>
  136.                                  </xsl:otherwise>
  137.                             </xsl:choose>
  138.                                  <xsl:attribute name="src">
  139.                                       <xsl:value-of select="local:LookupEntity(.)"/>
  140.                                  </xsl:attribute>
  141.                          </embed>
  142.                     </xsl:if>
  143.                   </xsl:when>
  144.                   <xsl:otherwise><!-- otherwise, it's a .jpg, place in <img> -->
  145.                       <img>
  146.                          <xsl:attribute name="src">
  147.                              <xsl:value-of select="local:LookupEntity(.)"/>
  148.                           </xsl:attribute>
  149.                       </img>
  150.                   </xsl:otherwise>
  151.              </xsl:choose>
  152.     </xsl:template>
  153.  
  154.     <msxsl:script implements-prefix="local"><![CDATA[
  155.     
  156.     function LookupEntity(nodeList) {
  157.     try {
  158.         var myNode = nodeList.item(0);
  159.         var ref = myNode.getAttribute("source");
  160.         var entity = myNode.ownerDocument.doctype.entities.getNamedItem(ref);
  161.         return entity.attributes.getNamedItem("SYSTEM").value;
  162.         }
  163.     catch(e) {
  164.         return "";
  165.         }
  166.     }
  167.     
  168.     function LookupEntityType(myNode) {
  169.     try {
  170.         var ref = myNode.getAttribute("source");
  171.         var entity = myNode.ownerDocument.doctype.entities.getNamedItem(ref);
  172.         return entity.attributes.getNamedItem("NDATA").value;
  173.         }
  174.     catch(e) {
  175.         return "";
  176.         }
  177.     }
  178.  
  179.    function tagit(nodeList) {
  180.    try {
  181.            var myNode = nodeList.item(0);
  182.         if (LookupEntityType(myNode) == "jpg")
  183.              return (0);
  184.         else
  185.         return (1); // "tiff"
  186.         }
  187.    catch(e) {
  188.         return "";
  189.         }
  190.     }
  191.  
  192.    function getHeight(nodeList) {
  193.    try {
  194.         // @96 pixels per inch on screen
  195.         // 300 pixels per inch for USPTO scans
  196.         var myNode = nodeList.item(0);
  197.         var x = myNode.getAttribute("height");
  198.         if (x == null)
  199.         return ("500")
  200.          else 
  201.            var tiffsize = myNode.attributes.getNamedItem("height").value * 84;
  202.            return tiffsize;
  203.        }
  204.        catch(e) {
  205.            return "";
  206.            }
  207.        }
  208.  
  209.    function getWidth(nodeList) {
  210.    try {
  211.            var myNode = nodeList.item(0);
  212.         var y =   myNode.getAttribute("width")
  213.            if (y == null)
  214.            return ("500")
  215.             else 
  216.         var tiffsize =  myNode.attributes.getNamedItem("width").value * 84;
  217.         return tiffsize;
  218.        }
  219.     catch(e) {
  220.         return "";
  221.         }
  222.     }
  223.         
  224.     function chooseDiv(nodeList) {
  225.     try {
  226.         var myNode = nodeList.item(0);    
  227.         if (getHeight(myNode) > 108) {
  228.             return (0);
  229.       }  else  {
  230.             return (1);
  231.           }  
  232.        } //
  233.     catch(e) {
  234.         return "";
  235.         }
  236.     }
  237. ]]></msxsl:script>
  238.  
  239. </xsl:stylesheet>