|
shouldn't you encode some data characters ( < > & ) to create valid XML?
(as you should for any code snippet you want to show in PRE tags)
|
|
|
|
|
The > is encoded, but it isn't double encoded. The .Net XSLT processor will forgive a greater than, but will sometimes choke on a less than. Inside of an xsl:text tag, though, less thans and greater thans may be legal (or maybe not... but the greater thans still work). In any event, the code colorizer shouldn't cut off code, even if the format is incorrect (if the HTML is icorrect, that's another matter entirely... but the HTML is encoded fine).
|
|
|
|
|
aspdotnetdev wrote: The > is encoded, but it isn't double encoded.
Just to clarify, I mean that the character is encoded in the pasted code sample. It is not encoded in the original XSLT sample.
|
|
|
|
|
aspdotnetdev wrote: the code colorizer shouldn't cut off code
that's the part I'm agreeing with most, however it still may be the browser is swallowing stuff due to incorrect HTML.
aspdotnetdev wrote: The > is encoded, but it isn't double encoded
IMO, and to make it very clear (I hope) it should be encoded one more time than your XML tags themselves.
aspdotnetdev wrote: the greater thans still work
yes, most often > seems to work without extra encoding, and < does or does not depending on circumstances (e.g. a forum message accepts them when the next character is a space or a digit). But it is not in accordance with the rules, some browser/HTML parser/XML parser might rightfully choke on them.
|
|
|
|
|
Just to be clear, it is only the XML that MAY be malformed (but will still work fine when put through an XSLT processor). The HTML is encoded as it should be. Every < is replaced by < and the same goes for the other characters. I selected "Encoded < When Pasting", so that should be perfectly fine. To demonstrate this, here is the XML code block from my above post, encoded further and wrapped in a PRE block with the LANG set to HTML:
<pre lang="xml"><xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:msxsl='urn:schemas-microsoft-com:xslt'
xmlns:theScript='urn:CustomScript'>
<xsl:output omit-xml-declaration='yes' method='text'
media-type='text/plain' indent='no' />
<xsl:variable name='displayme' />
<msxsl:script implements-prefix='theScript' language='C#'>
<![CDATA[
public string HelloName(string name)
{
return "Hello " + name;
}
]]>
</msxsl:script>
<xsl:template match='/'>
<xsl:text disable-output-escaping='yes'>Print Integers > 3</xsl:text>
<xsl:apply-templates select='Root/Numbers' />
Script Result: <xsl:value-of select='theScript:HelloName("Joe")' />
Done: <xsl:value-of select='$displayme' />
</xsl:template>
<xsl:template match='Numbers'>
Numbers:<xsl:apply-templates select='Integer[@value > 3]' />
</xsl:template>
<xsl:template match='Integer'>
Integer: <xsl:value-of select='@value' />
</xsl:template>
</xsl:stylesheet></pre>
The HTML is definitely not the issue. It's the colorizers interpretation of the XML that is the problem.
|
|
|
|
|
Sorry but I don't like the > which sits
here
|
V
<xsl:text disable-output-escaping='yes'>Print Integers > 3</xsl:text>
I'm not familiar with XSL, bowever I'm pretty convinced it should be escaped.
FWIW: Yes, it is unfortunate things may go wrong when escaping isn't applied correctly, and yes it would be nice if the forum and the browser would be as tolerant as the system that is intended to process your code.
FWIW2: jeez, these forums are much harder without proper mail notifications.
|
|
|
|
|
Luc Pattyn wrote: jeez, these forums are much harder without proper mail notifications.
Sucker! Notifications have been working fine for me. Maybe Jim just doesn't like you.
|
|
|
|
|
You must be living in an alternate reality...
|
|
|
|
|
I agree with Luc.
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
You agree that "it would be nice if the forum and the browser would be as tolerant as the system that is intended to process your code"?
|
|
|
|
|
I agree that "I'm pretty convinced it should be escaped"
Even so, it's easy enough to add some code that will take <[non-alphanumeric] and convert it to <[non-alphanumeric]
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
I think what you mean is change this:
<xsl:text>xyz > abc</xsl:text>
Into this:
<xsl:text>xyz > abc</xsl:text>
That might change the meaning of the code (that's basically what I had to do though, unfortunately)... I'm not sure, but I think XSLT interprets anything inside of an XSL:TEXT block as a string literal (so a greater than would be output as a greater than and an ampersand would be output as an ampersand... not sure though). Also, I don't see how a character being alphanumeric or not is relevant.
I can't see any way to get the above to display with XML as the LANG:
<xsl:text>xyz > abc</xsl:text>
Are you saying I should modify the code content so the colorizer doesn't cut off the code? Probably a suitable workaround for most every scenario, but still seems like a bug, and one that takes time to figure out how to fix.
|
|
|
|
|
Luc Pattyn wrote: jeez, these forums are much harder without proper mail notifications
How are they now?
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
mail just arrived, 9 hours late.
full header included:
softfail (mta1148.mail.mud.yahoo.com: domain of transitioning forums@codeproject.com does not designate 65.39.148.44 as permitted sender)
|
|
|
|
|
We're slowly corralling things into shape. Mail is always the slowest to get sorted.
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
it started to work promptly for me some 10 minutes ago.
|
|
|
|
|
As luck would have it, it appears this may have just happend to somebody else here:
VisualLive wrote: i tried to use PRE tag but when i post the code many lines of code disappear
|
|
|
|
|
That guy didn't HTML encode any HTML entities. I've corrected it.
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
I was sitting with 5 articles, and then added the GadgetPacker one the other night.
It still shows 5 as the tally, both at the top of the My Articles and the table on the right of member profile, however all 6 are listed.
Something broke?
Dave
Find Me On: Web| Facebook| Twitter| LinkedIn
CPRepWatcher now available as Packaged Chrome Extension, visit my articles for link.
|
|
|
|
|
Is it perhaps the case that it doesn't add the article to your tally until it has been approved?
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
It is approved.
Dave
Find Me On: Web| Facebook| Twitter| LinkedIn
CPRepWatcher now available as Packaged Chrome Extension, visit my articles for link.
|
|
|
|
|
I haven't received an Insider for a number of days - it's not in my junk mail, the checkbox is still checked in my profile, my email address hasn't changed etc...
Is it just me?
|
|
|
|
|
Because we've moved IP addresses we're seeing all sorts of email weirdness. I'm spending today sorting through them.
Emails are getting out, just not to 100% of the members. Unfortunately MX records take a few days to propogate.
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
Thanks for the reply... just so you know, I'm still not receiving them.
|
|
|
|
|
You've checked your spam filters, added us to uyour whitelists, burned some sage, - you know, the usual things?
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|