home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2004 June / VPR0406.ISO / STARSUITE7 / EVALUATION / windows / adabas / f0_001 / user_registry.xsl
Extensible Markup Language  |  2003-05-27  |  6KB  |  158 lines

  1. <?xml version="1.0"?>
  2. <xsl:stylesheet version="1.0" xmlns:cfg="http://openoffice.org/2000/registry/instance"  xmlns:oor="http://openoffice.org/2001/registry" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" cfg:package="org.openoffice.Office" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xmlns="http://www.w3.org/2001/XMLSchema">
  3.  
  4.     <xsl:output encoding="UTF-8"/>
  5.  
  6.     <xsl:template match="/*">
  7.         <xsl:element name="oor:component-data">
  8.             <xsl:call-template name="component-attribs"/>
  9.             <xsl:apply-templates/>
  10.         </xsl:element>
  11.     </xsl:template>
  12.  
  13.     <xsl:template match="/*//*">
  14.         <xsl:choose>
  15.             <xsl:when test="(count(@cfg:type) and @cfg:type!='set') or @xsi:null='true'">
  16.                 <xsl:call-template name="prop-element"/>
  17.             </xsl:when>
  18.             <xsl:when test="name()='cfg:value'">
  19.                 <xsl:call-template name="value-element"/>
  20.             </xsl:when>
  21.             <xsl:otherwise>
  22.                 <xsl:call-template name="node-element"/>
  23.             </xsl:otherwise>
  24.         </xsl:choose>
  25.     </xsl:template>
  26.  
  27.     <xsl:template name="component-attribs">
  28.         <xsl:attribute name="xmlns:oor">http://openoffice.org/2001/registry</xsl:attribute>
  29.         <xsl:attribute name="xmlns:xs">http://www.w3.org/2001/XMLSchema</xsl:attribute>
  30.         <xsl:attribute name="xmlns:xsi">http://www.w3.org/2001/XMLSchema-instance</xsl:attribute>
  31.         <xsl:attribute name="oor:name">
  32.             <xsl:choose>
  33.                 <xsl:when test="@cfg:name!=''">
  34.                     <xsl:value-of select="@cfg:name"/>
  35.                 </xsl:when>
  36.                 <xsl:otherwise>
  37.                     <xsl:value-of select="local-name()"/>
  38.                 </xsl:otherwise>
  39.             </xsl:choose>
  40.         </xsl:attribute>
  41.         <xsl:attribute name="oor:package">
  42.             <xsl:value-of select="@cfg:package"/>
  43.         </xsl:attribute>
  44.     </xsl:template>
  45.  
  46.     <xsl:template name="node-element">
  47.         <xsl:element name="node">
  48.             <xsl:call-template name="node-attribs"/>
  49.             <xsl:apply-templates/>
  50.         </xsl:element>
  51.     </xsl:template>
  52.  
  53.     <xsl:template name="node-attribs">
  54.         <xsl:attribute name="oor:name">
  55.             <xsl:choose>
  56.                 <xsl:when test="@cfg:name!=''">
  57.                     <xsl:value-of select="@cfg:name"/>
  58.                 </xsl:when>
  59.                 <xsl:otherwise>
  60.                     <xsl:value-of select="local-name()"/>
  61.                 </xsl:otherwise>
  62.             </xsl:choose>
  63.         </xsl:attribute>
  64.         <xsl:choose>
  65.             <xsl:when test="@state='deleted'">
  66.                 <xsl:attribute name="oor:op">remove</xsl:attribute>
  67.             </xsl:when>
  68.             <xsl:when test="@state='default'">
  69.                 <xsl:attribute name="oor:op">reset</xsl:attribute>
  70.             </xsl:when>
  71.             <xsl:when test="@state='replaced' or (../@cfg:element-type!='' and ancestor::*/@state='replaced')">
  72.                 <xsl:attribute name="oor:op">replace</xsl:attribute>
  73.             </xsl:when>
  74.             <xsl:otherwise/>
  75.         </xsl:choose>
  76.     </xsl:template>
  77.  
  78.     <xsl:template name="prop-element">
  79.         <xsl:element name="prop">
  80.             <xsl:call-template name="prop-attribs"/>
  81.             <xsl:choose>
  82.                 <xsl:when test="cfg:value">
  83.                     <xsl:apply-templates select="cfg:value"/>
  84.                 </xsl:when>
  85.                 <xsl:otherwise>
  86.                     <xsl:call-template name="value-element"/>
  87.                 </xsl:otherwise>
  88.             </xsl:choose>
  89.         </xsl:element>
  90.     </xsl:template>
  91.  
  92.     <xsl:template name="prop-attribs">
  93.         <xsl:attribute name="oor:name">
  94.             <xsl:choose>
  95.                 <xsl:when test="@cfg:name!=''">
  96.                     <xsl:value-of select="@cfg:name"/>
  97.                 </xsl:when>
  98.                 <xsl:otherwise>
  99.                     <xsl:value-of select="local-name()"/>
  100.                 </xsl:otherwise>
  101.             </xsl:choose>
  102.         </xsl:attribute>
  103.         <xsl:choose>
  104.             <xsl:when test="@state='deleted'">
  105.                 <xsl:attribute name="oor:op">remove</xsl:attribute>
  106.             </xsl:when>
  107.             <xsl:when test="@state='default'">
  108.                 <xsl:attribute name="oor:op">reset</xsl:attribute>
  109.             </xsl:when>
  110.             <xsl:when test="@state='replaced' or ../@cfg:element-type!=''">
  111.                 <xsl:attribute name="oor:op">replace</xsl:attribute>
  112.             </xsl:when>
  113.             <xsl:otherwise/>
  114.         </xsl:choose>
  115.         <xsl:if test="@cfg:type!=''">
  116.             <xsl:choose>
  117.                 <xsl:when test="@cfg:type='binary'">
  118.                     <xsl:choose>
  119.                         <xsl:when test="@cfg:derivedBy='list'">
  120.                             <xsl:attribute name="oor:type">oor:hexBinary-list</xsl:attribute>
  121.                         </xsl:when>
  122.                         <xsl:otherwise>
  123.                             <xsl:attribute name="oor:type">xs:hexBinary</xsl:attribute>
  124.                         </xsl:otherwise>
  125.                     </xsl:choose>
  126.                 </xsl:when>
  127.                 <xsl:otherwise>
  128.                     <xsl:choose>
  129.                         <xsl:when test="@cfg:derivedBy='list'">
  130.                             <xsl:attribute name="oor:type">oor:<xsl:value-of select="@cfg:type"/>-list</xsl:attribute>
  131.                         </xsl:when>
  132.                         <xsl:otherwise>
  133.                             <xsl:attribute name="oor:type">xs:<xsl:value-of select="@cfg:type"/></xsl:attribute>
  134.                         </xsl:otherwise>
  135.                     </xsl:choose>
  136.                 </xsl:otherwise>
  137.             </xsl:choose>
  138.         </xsl:if>
  139.     </xsl:template>
  140.  
  141.     <xsl:template name="value-element">
  142.         <xsl:element name="value">
  143.             <xsl:if test="@xml:lang!=''">
  144.                 <xsl:attribute name="xml:lang"><xsl:value-of select="@xml:lang"/></xsl:attribute>
  145.             </xsl:if>
  146.             <xsl:choose>
  147.                 <xsl:when test="@xsi:null = 'true'">
  148.                     <xsl:attribute name="xsi:nil">true</xsl:attribute>
  149.                 </xsl:when>
  150.                 <xsl:otherwise>
  151.                     <xsl:value-of select="."/>
  152.                 </xsl:otherwise>
  153.             </xsl:choose>
  154.         </xsl:element>
  155.     </xsl:template>
  156.  
  157. </xsl:stylesheet>
  158.