473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Outputting ASP.NET tags using XSLT

Hi,

Oleg's answer about attribute value templates led me to look back at a
different problem, and wonder if someone else had solved it.

I want to output an ASP.NET page. Thus I need to output ASP.NET tags and
HTML tags.

<%@ Page Language= etc...

and
<HTML> etc.

OK, so I use html output and can't get the directive output. <% gives an
error and &lt;% outputs exactly that which Visual Studio (at least) fails to
regonize.

So I use text output, and can get the page directive output correctly using
&lt;%. However, I have to escape everysingle < in the file, or the tag is
ignored and not output. It works, but man is it ugly.

A sample is below so you can point out any issues you see with it. The
garbage namespaces are from some messing around I was doing this morning on
the problem (it currently fails to output the HTML tags).
--
Kathleen Dollard
Microsoft MVP
Author "Code Generation in Microsoft .NET"

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dbs="http://kadgen/DatabaseStructure"
xmlns:orm="http://kadgen.com/KADORM.xsd"
xmlns:ui="http://kadgen.com/UserInterface.xsd"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:net="http://kadgen.com/StandardNETSupport.xsd"
xmlns:asp="asdf"
xmlns:uc1="QWER"
xmlns=" HTMLSDFTUF">
<xsl:import href="webSupport.xslt"/>
<xsl:import href="../../Chapter 8/BusinessObjects/CSLASupport.xslt"/>
<xsl:output method="text" encoding="UTF-8" indent="yes"/>
<xsl:preserve-space elements="*" />

<xsl:param name="Name"/>
<xsl:param name="filename"/>
<xsl:param name="database"/>
<xsl:param name="gendatetime"/>
<xsl:param name="BusinessObject"/>

<xsl:variable name="projnamespace" select="//ui:UIRoot/@ProjectNamespace"/>
<xsl:variable name="objectname" select="$BusinessObject"/>
<xsl:variable name="objectsingular"
select="//orm:Object[@Name=$objectname]/@Name"/>

<xsl:template match="/">
<xsl:apply-templates select="//orm:Object[@Name=$objectname]"
mode="Object"/>
</xsl:template>

<xsl:template match="orm:Object" mode="Object">
&lt;%@ Page Language="vb" AutoEventWireup="false"
Codebehind="<xsl:value-of select="$objectsingular"/>Edit.aspx.vb"
Inherits="<xsl:value-of
select="concat($projnamespace,'.codebehind',
$objectsingular)"/>Edit"%>
&lt;%@ Register TagPrefix="uc1" TagName="Header" Src="..\..\Header.ascx" %>
<!--<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">-->
<HTML>
<HEAD>
<title><xsl:value-of select="$objectsingular"/>Edit</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"/>
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE"/>
<meta content="JavaScript" name="vs_defaultClientScript"/>
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema"/>
</HEAD>
<body>
<form id="{$objectsingular}Edit"
method="post" runat="server">
<P>
<uc1:header id="Header1" runat="server">
</uc1:header>
</P>
<P>
<asp:label id="Label2"
runat="server" Font-Names="Bauhaus 93"
Font-Size="XX-Large">
Edit <xsl:value-of select="$objectsingular"/>
</asp:label></P>
</form>
</body>
</HTML>

</xsl:template>
</xsl:stylesheet>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="AssignmentEdit.aspx.vb"
Inherits="WebPTracker.codebehindAssignmentEdit"%>
<%@ Register TagPrefix="uc1" TagName="Header" Src="..\..\Header.ascx" %>
AssignmentEdit
Edit Assignment
Nov 12 '05 #1
8 5994
Kathleen Dollard wrote:
I want to output an ASP.NET page. Thus I need to output ASP.NET tags and
HTML tags.
This is what disable-output-escaping feature was disagned to facilitate,
see http://www.w3.org/TR/xslt#disable-output-escaping.
disable-output-escaping feature is greately abused by people, but it's
primary goal is to allow to output nonXML/nonHTML formats, such as
ASP/JSP/XQuery/SQL/etc.
<%@ Page Language= etc...

and
<HTML> etc.

OK, so I use html output and can't get the directive output. <% gives an
error and &lt;% outputs exactly that which Visual Studio (at least) fails to
regonize.


Try
<xsl:text disable-output-escaping="yes">&lt;%@ Page language="c#"
%></xsl:text>

This allows to output ASP tags while transforming using HTML or XML
output method.

--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog
Nov 12 '05 #2
Oleg Tkachenko <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message news:<Ox**************@TK2MSFTNGP12.phx.gbl>...
Kathleen Dollard wrote:
I want to output an ASP.NET page. Thus I need to output ASP.NET tags and
HTML tags.


This is what disable-output-escaping feature was disagned to facilitate,
see http://www.w3.org/TR/xslt#disable-output-escaping.
disable-output-escaping feature is greately abused by people, but it's
primary goal is to allow to output nonXML/nonHTML formats, such as
ASP/JSP/XQuery/SQL/etc.


While Oleg is right about DOE, I'd recommend not to use DOE even in
such cases (as it may become a little bad habbit).

The attribute value: method="text" was intended for cases exactly like
this.

Certainly, one has to escape all "<" and "&" characters, but this will
help to never forget that the result is *not* a well-formed xml
document.

Another approach, which probably is the best compromise between
convenience and to using 100% conformant features of XSLT, is to use a
dummy namespace, bind the "asp" prefix to it, perform the
transformation and then update the result and remove the namespace
declaration.
Dimitre Novatchev.
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
Nov 12 '05 #3
I gave got a similar problem as discussed, but I have added the recommendations to my code at it still does not work. Has anyone got a simple solution that they can share with me? i.e. just one user control returning XM

I would bery much appreciate any examples or references as this thing has been quite frustratin

Thankyou in advanced
Nov 12 '05 #4
>>This is what disable-output-escaping feature was disagned to facilitate,
see http://www.w3.org/TR/xslt#disable-output-escaping.
disable-output-escaping feature is greately abused by people, but it's
primary goal is to allow to output nonXML/nonHTML formats, such as
ASP/JSP/XQuery/SQL/etc.
While Oleg is right about DOE, I'd recommend not to use DOE even in
such cases (as it may become a little bad habbit).

The attribute value: method="text" was intended for cases exactly like
this.

Certainly, one has to escape all "<" and "&" characters, but this will
help to never forget that the result is *not* a well-formed xml
document.


I've run into a similar problem, that basically runs along the same
lines. I'm trying to use a FOR XML query with XmlDataDocument and I keep
getting.

<NewDataSet>
<Keywords>
<XML_F52E2B61-18A1-11d1-B105-00805F49916B>
&lt;nodeset&gt;
Nodeset with all special characters escaped.
&lt;/nodeset&gt;
</XML_F52E2B61-18A1-11d1-B105-00805F49916B>
</Keywords>
</NewDataSet>

Now, this may simply be a problem with how I'm doing it, but I still
think it might be usefull to have an easy way to convert these to their
character equivlents using XSL.
Another approach, which probably is the best compromise between
convenience and to using 100% conformant features of XSLT, is to use a
dummy namespace, bind the "asp" prefix to it, perform the
transformation and then update the result and remove the namespace
declaration.


Is there a schema for the asp: tags used with asp.net?

Nov 12 '05 #5

Is there a schema for the asp: tags used with asp.net?


AFAIK, there's no asp xml schema.
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html


Nov 12 '05 #6
Anas M. Nebuchadnezzar XXXVII wrote:
Is there a schema for the asp: tags used with asp.net?


ASP.NET syntax isn't XML, so I doubt there is a schema available.

--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #7
Hi Andrew,

Have you tried to use the disable-output-escaping feature? Here is an
example:

<xsl:template match="description">
<xsl:value-of select="." disable-output-escaping="yes" />
</xsl:template>

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #8

"Dimitre Novatchev [MVP XML]" <dn********@yahoo.com> wrote in message
news:c2*************@ID-152440.news.uni-berlin.de...

Is there a schema for the asp: tags used with asp.net?


AFAIK, there's no asp xml schema.


And, of course, there cannot be one as ASP is not an application of XML.
Nov 12 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Spence Hackney | last post by:
I am using ASP.NET to get XML data from a database, style it with an XSLT, and then display it as HTML to a browser. The content in the database, which becomes my XML, has HTML tags embedded in...
3
by: Francis Hwang | last post by:
Hi, Maybe this is a newbie question, but: Is there a way to output an element's contents -- including contained nodes and free-form text -- without the containing tags? I can imagine that...
2
by: Joe | last post by:
How would you preserve tags from an XML element in XSLT output.. Example: XML document has an ELEMENT "SECTION" allowing contained HTML This element might have an element such as <A...
4
by: Luke Dalessandro | last post by:
I have some XML data that has mixed content XML tags that embed XHTML tags, for instance: <note>Somebody wrote this note in XHTML and wanto to <a href="link.html" target="_new">link</a> to a...
8
by: David Dorward | last post by:
I'm looking for an XSLT that I can use to transform XHTML 1.0 Strict into HTML 4.01. Does anyone know of a nice prewritten one? -- David Dorward ...
2
by: Richard L Rosenheim | last post by:
Is it possible to include addition tags in a XSLT file, that the XSLT processor will, for all practical purposes, ignore? What I'm looking to do is to include a section to contain information...
4
by: dwergkees | last post by:
Hi, Got a litte problem here. I'm trying to create a XSLT file that will do a transformation from WordML format (MS Word XML format, see...
2
by: Andy | last post by:
Hi, I have an ASP.NET webpage that contains an ASP.NET XML control. This control accepts an XSLT stylesheet and XML document which it then uses to render HTML code where the XML control is...
1
by: mikepmyers | last post by:
I've done some research online and turned up with results that did not sit well with me. I’m using the System.Xml.XslCompiledTransform class as recommended by MS; however, it’s creating self-closing...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.