【问题标题】:Render App.config/Web.config files via XSLT通过 XSLT 呈现 App.config/Web.config 文件
【发布时间】:2008-10-15 09:59:19
【问题描述】:

有没有人有 XSLT 可以获取 app.config 并将其呈现为非技术人员可口的格式?

目的主要是提供信息,但具有验证 XML 的良好副作用(如果它被设为无效,则不会呈现)

【问题讨论】:

    标签: .net xslt app-config


    【解决方案1】:

    要展示的解决方案初稿

    • 连接字符串
    • 应用设置

    在 app.config 中敲这个:

    <?xml-stylesheet type="text/xsl" href="display-config.xslt"?>
    

    这是 display-config.xslt 的内容:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
      <xsl:template match="/">
       <html>
        <body>
         <h2>Settings</h2> 
         <xsl:apply-templates /> 
        </body>
       </html>
      </xsl:template>      
    
    
      <xsl:template match="connectionStrings">
       <h3>Connection Strings</h3>
       <table border="1">
        <tr bgcolor="#abcdef">
         <th align="left">Name</th>
         <th align="left">Connection String</th>
        </tr>
        <xsl:for-each select="add">
         <tr>
          <td><xsl:value-of select="@name"/></td>
          <td><xsl:value-of select="@connectionString"/></td>
         </tr>
        </xsl:for-each>
       </table>
      </xsl:template>
    
    
      <xsl:template match="appSettings">
       <h3>Settings</h3>
       <table border="1">
        <tr bgcolor="#abcdef">
         <th align="left">Key</th>
         <th align="left">Value</th>
        </tr>
        <xsl:for-each select="add">
         <tr>
          <td><xsl:value-of select="@key"/></td>
          <td><xsl:value-of select="@value"/></td>
         </tr>
        </xsl:for-each>
       </table>
      </xsl:template>
    </xsl:stylesheet>
    

    【讨论】:

      【解决方案2】:

      您正在寻找哪种类型的转化?只是为了提供信息?您希望转换什么级别的细节?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-08-13
        • 2016-03-13
        • 2014-01-19
        • 2017-04-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多