1

I need to use XSLT to output an aspx file that includes special ASP directives like,

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

and

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

How is this accomplished using XSLT?

The following style sheet excerpt does embed the Page and command does not execute?

<?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>
4

1 回答 1

0

我认为您需要使用 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>
于 2013-01-04T22:08:16.230 回答