【问题标题】:How to embed ASPX page directives in XSLT?如何在 XSLT 中嵌入 ASPX 页面指令?
【发布时间】:2013-01-04 20:28:55
【问题描述】:

我需要使用 XSLT 输出一个包含特殊 ASP 指令的 aspx 文件,例如,

<%@ Page Title="Squire" Language="C#" MasterPageFile="~/Site1.Master"  %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

这是如何使用 XSLT 完成的?

以下样式表摘录确实嵌入了页面并且命令不执行?

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
  <xsl:output method="text" cdata-section-elements="aspx" />
  <xsl:template match="/">
    <aspx>
      <![CDATA[<%@ Page="" Title="Top New York City (Manhattan) Plastic Surgeons" Language="C#" MasterPageFile="~/Site1.Master" %>
      <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">]]>
    </aspx>
    <xsl:apply-templates/>
    <aspx><![CDATA[</asp:Content>]]></aspx>
  </xsl:template>

  <xsl:template match="PlaceDetailsResponse">
    <div class="page">
      <div style="float:left; width:100%;">
        <img src="{//icon}" alt="type" style="float:left" ></img>
        <h1 style="float:left;">
          <xsl:value-of select="@ReportHeading"/>
        </h1>
        <img src="images/info-icon.jpg" alt="information" style="float:right;margin-right:2px; height: 32px;"></img>
        <div id="info"></div>
      </div>
      <![CDATA[
        <script type="text/javascript">
            <!--
                google_ad_client = "ca-pub-3982825388677642";
                /* MobileBottom */
                google_ad_slot = "3380596110";
                google_ad_width = 468;
                google_ad_height = 60;
                //-->
        </script>
        <script type="text/javascript"
          src  ="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>
      ]]>
    </div>

    <div style="font-size:smaller; clear:both; border-bottom:double silver; padding:5px;">
        Sort by: <a href="*" >Places Ranking</a><a href="*" style="margin-left:5px;" >Yelp Ranking</a>
    </div>
  </xsl:template>

<xsl:template match="PlaceDetailsResponse/result">

    ... a couple more templates follow
</xsl:template>

【问题讨论】:

  • What have you tried?你被困在哪里了?
  • 我尝试在 块中设置一个包含 Page 指令的属性 (PageDirective),并将
  • 应该可以的。发布您的尝试。

标签: asp.net xslt


【解决方案1】:

我认为您需要使用 disable-output-escaping - 像这样:

<xsl:text disable-output-escaping="yes">&lt;%@ Page="" Title="Top New York City (Manhattan) Plastic Surgeons" Language="C#" MasterPageFile="~/Site1.Master" %&gt;</xsl:text>

【讨论】:

  • 这正是我所需要的。谢谢。如何在 之后强制换行?
  • 尝试在 xsl:text 中附加字符串&amp;#xA;
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多