Click here to Skip to main content
16,012,223 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: deriving an integer value Pin
Nick Parker3-Sep-02 8:10
protectorNick Parker3-Sep-02 8:10 
Generalpassing values when redirecting Pin
mcm3-Sep-02 5:06
mcm3-Sep-02 5:06 
GeneralRe: passing values when redirecting Pin
Paul Riley3-Sep-02 5:41
Paul Riley3-Sep-02 5:41 
GeneralRe: passing values when redirecting Pin
Nick Parker3-Sep-02 8:14
protectorNick Parker3-Sep-02 8:14 
GeneralTemplateColumn:DropDownList Edit Selected Item Pin
MStanbrook2-Sep-02 15:11
MStanbrook2-Sep-02 15:11 
GeneralRe: TemplateColumn:DropDownList Edit Selected Item Pin
Todd Smith2-Sep-02 15:36
Todd Smith2-Sep-02 15:36 
GeneralRe: TemplateColumn:DropDownList Edit Selected Item Pin
MStanbrook2-Sep-02 15:50
MStanbrook2-Sep-02 15:50 
GeneralMy Evil XSLT and ASP.NET Code (long) Pin
Domenic Denicola2-Sep-02 7:12
Domenic Denicola2-Sep-02 7:12 
Problem statement: given a document like this:

<?xml version="1.0" encoding="utf-8"?>
<Page xmlns="/PageWriter/TemplateSchema.xsd" xmlns:XHTML="http://www.w3.org/1999/xhtml">
  <Head>
    <!-- Irrelevant stuff here -->
  </Head>
  <Body>
    <XHTML:p>See, this is how XHTML elements work.</XHTML:p>

    <ASP.NET>Response.Write("And this is how ASP.NET is supposed to work!");</ASP.NET>
  </Body>
</Page>


called Doc.mhcx (MadHamster Creations XML page format), I want to produce an .aspx file like this:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
  <head>
    <!-- Irrelevant stuff -->
  </head>

  <body>
    <p>See, this is how XHTML elements work.</p>
    <% Response.Write("And this is how ASP.NET is supposed to work!"); %>
  </body>
</html>


And then serve it up to the client.




Progress so far: I can do everything, except when my <ASP.NET> tags get involved. Then, given a simple <xsl:value-of select="." />, it will transform all my <s, >s, and &s into their entity equivelants. Needless to say, this is bad.

I got around this with an almost painless hack for JavaScript by this code:

<xsl:text disable-output-escaping="yes"><![CDATA[<% Response.Write(PageWriter.UnescapeText(@"]]></xsl:text>
<xsl:value-of select="translate(., '"', '░')" />
<xsl:text disable-output-escaping="yes"><![CDATA[")); %>]]></xsl:text>


Where the current context (.) is the JavaScript code and PageWriter.UnescapeText is a ASP.NET function that will fix all the <s, >s, and &s that XSL mangled. There's also an added complication that because this is going to be a string paramter, I use XSL to turn all "s into &#9617;s (░s, if the browser will display this) on the assumption that nobody will ever use that character in JS code, and then PageWriter.UnescapeText turns those weird characters back into "s. This is to avoid making every " in the JS end the parameter to PageWriter.UnescapeText. Ugly, but it works.

But this obviously doesn't work for ASP.NET, because I can't pass ASP.NET code to an ASP.NET function (unless there's some JS eval type function I'm not aware of somewhere?) So...




Current idea for a hack, the implementation of which is not working right now:

If the .mhcx document has <ASP.NET> tags (inputDoc.GetElementsByTagName("ASP.NET").Count > 0), then do special things, like:

create a temporary .mhcx file with all <s, >s, and &s replaced by far-out Unicode characters that nobody will ever use. Then do normal transformation of .mhcx to .aspx. Of course, at this point we've still got weird Unicode chars, so read in the .aspx file, turn the chars back into <s, >s, and &s, then write out the .aspx file again.

Finally, display this .aspx file to the client.




Notes: This is really rather repulsive.

The best solution would be to make XSL somehow spit out <s, >s, and &s unmolested. That fixes everything, really. No need for any special cases, even for JavaScript code.

Another not-so-great solution would be to have my output format for XSL be text instead of XML. Then it won't mangle things, but... that's just wrong, y'know?

I guess I could also give up XSL entirely and just use ASP.NET processing... unhappy, but painless.

Otherwise, I'm kind of at a loss.

Please note that speed won't be an issue. Although all this processing is currently done on every request, in the future I'll just have a .exe that will scan all .mhcx files on my local server and turn them into .aspxs. Then, assuming this .exe is run after any changes to .mhcx files, all the .mhcx handler will have to do is lookup the URL for the corresponding .aspx, which is quite simple and speedy.

Help?

-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations

"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."

GeneralRe: My Evil XSLT and ASP.NET Code (long) Pin
Domenic Denicola2-Sep-02 8:29
Domenic Denicola2-Sep-02 8:29 
Generalredirecting a user based on combo-box selection Pin
mcm2-Sep-02 3:59
mcm2-Sep-02 3:59 
GeneralRe: redirecting a user based on combo-box selection Pin
Paul Watson2-Sep-02 5:33
sitebuilderPaul Watson2-Sep-02 5:33 
GeneralRe: redirecting a user based on combo-box selection Pin
mcm2-Sep-02 5:54
mcm2-Sep-02 5:54 
GeneralRe: redirecting a user based on combo-box selection Pin
Paul Watson2-Sep-02 5:59
sitebuilderPaul Watson2-Sep-02 5:59 
GeneralDHTML collapsable tables Pin
benjymous1-Sep-02 23:54
benjymous1-Sep-02 23:54 
GeneralRe: DHTML collapsable tables Pin
Paul Watson2-Sep-02 5:44
sitebuilderPaul Watson2-Sep-02 5:44 
GeneralRe: DHTML collapsable tables Pin
benjymous2-Sep-02 6:23
benjymous2-Sep-02 6:23 
GeneralRe: DHTML collapsable tables Pin
Anonymous3-Sep-02 1:59
Anonymous3-Sep-02 1:59 
GeneralRe: DHTML collapsable tables Pin
Anonymous3-Sep-02 2:02
Anonymous3-Sep-02 2:02 
GeneralRe: DHTML collapsable tables Pin
alex.barylski3-Sep-02 23:20
alex.barylski3-Sep-02 23:20 
GeneralRe: DHTML collapsable tables Pin
Paul Watson3-Sep-02 23:34
sitebuilderPaul Watson3-Sep-02 23:34 
GeneralCDONTS sends to Badmail Pin
Megan Forbes31-Aug-02 6:44
Megan Forbes31-Aug-02 6:44 
GeneralRe: CDONTS sends to Badmail Pin
TigerNinja_3-Sep-02 7:58
TigerNinja_3-Sep-02 7:58 
GeneralWeird Javascript issue Pin
Jamie Nordmeyer30-Aug-02 11:13
Jamie Nordmeyer30-Aug-02 11:13 
GeneralRe: Weird Javascript issue Pin
Richard Deeming2-Sep-02 0:51
mveRichard Deeming2-Sep-02 0:51 
GeneralParser error: could'nt load .global file Pin
kinf30-Aug-02 5:37
kinf30-Aug-02 5:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.