...few months ago, we deployed an XML-XSLT website that contains rich data content. There are rumors that it doesn't do much in SEO. Since we can't just accept something unless we tried it ourselves, we decided to deploy a version of a blog website....
Showing posts with label xslt. Show all posts
Showing posts with label xslt. Show all posts
The XML page cannot be displayed - Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. Access is denied. Error processing resource
The XML page cannot be displayed -
Cannot view XML input using XSL style sheet.
Please correct the error and then click the Refresh button, or try again later.
Access is denied. Error processing resource
On my continued experiment on dynamic XSLT website. It seems that the browsers WILL NOT PROCESS XSL stylesheets if the URL in the href attribute is different to the current document's URL because of cross-domain issue. Although I understand that if they don't do this, every pages might end up X-Domain attacked, but having it denied even on same DOMAIN is just absurd...
So, if you got an XML laced with
< ?xml-stylesheet type="text/xsl" href="http://sitename.com/index.xsl"?>
on any xml documents in http://sitename.com/myxmlfile.xml
the referenced stylesheet will be processed, but if your site does something like SEO optimization and handles specific file by subdomain...
< ?xml-stylesheet type="text/xsl" href="http://internal.sitename.com/index.xsl"?>
this will display for any xml documents under internal.sitename.com/myxmldoc.xml ...
So, the browsers got a narrow understanding of cross-domains, treating it as cross-URL. It should be called Cross URL instead of cross domain protection.
Cannot view XML input using XSL style sheet.
Please correct the error and then click the Refresh button, or try again later.
Access is denied. Error processing resource
On my continued experiment on dynamic XSLT website. It seems that the browsers WILL NOT PROCESS XSL stylesheets if the URL in the href attribute is different to the current document's URL because of cross-domain issue. Although I understand that if they don't do this, every pages might end up X-Domain attacked, but having it denied even on same DOMAIN is just absurd...
So, if you got an XML laced with
< ?xml-stylesheet type="text/xsl" href="http://sitename.com/index.xsl"?>
on any xml documents in http://sitename.com/myxmlfile.xml
the referenced stylesheet will be processed, but if your site does something like SEO optimization and handles specific file by subdomain...
< ?xml-stylesheet type="text/xsl" href="http://internal.sitename.com/index.xsl"?>
this will display for any xml documents under internal.sitename.com/myxmldoc.xml ...
So, the browsers got a narrow understanding of cross-domains, treating it as cross-URL. It should be called Cross URL instead of cross domain protection.
SQL XML query escapes HTML tags
just after the big show stopper, I'm now dealing with another one..
Lets say for now, I have something like this
SELECT 'and i'd give up forever to touch ' 'line'
UNION
SELECT 'you cause i know that you feel me so love, your the closest to heaven that i've ever been ' 'line'
UNION
SELECT 'and i don't want to go home right ' 'line'
UNION
SELECT 'now and all i can taste is your sweetness ' 'line'
UNION
SELECT 'and all i can breath is your life ' 'line'
FOR XML PATH('test'),TYPE
and, I run it... I'll get those angle brackets escaped (< and >)
fortunately, there is a way to still make those angle brackets, but will lose the XML thing by using value
SELECT 'and i'd give up forever to touch ' 'line'
UNION
SELECT 'you cause i know that you feel me so love, your the closest to heaven that i've ever been ' 'line'
UNION
SELECT 'and i don't want to go home right ' 'line'
UNION
SELECT 'now and all i can taste is your sweetness ' 'line'
UNION
SELECT 'and all i can breath is your life ' 'line'
FOR XML PATH('test'),TYPE).value('(/test)[1]','NVARCHAR(MAX)')
will keep the angle brackets, but it is once again, an NVARVCHAR field...
much of an interest, but doesn't help me because I have a large nested XML PATH query.. :(
Lets say for now, I have something like this
SELECT 'and i'd give up forever to touch ' 'line'
UNION
SELECT 'you cause i know that you feel me so love, your the closest to heaven that i've ever been ' 'line'
UNION
SELECT 'and i don't want to go home right ' 'line'
UNION
SELECT 'now and all i can taste is your sweetness ' 'line'
UNION
SELECT 'and all i can breath is your life ' 'line'
FOR XML PATH('test'),TYPE
and, I run it... I'll get those angle brackets escaped (< and >)
fortunately, there is a way to still make those angle brackets, but will lose the XML thing by using value
SELECT 'and i'd give up forever to touch ' 'line'
UNION
SELECT 'you cause i know that you feel me so love, your the closest to heaven that i've ever been ' 'line'
UNION
SELECT 'and i don't want to go home right ' 'line'
UNION
SELECT 'now and all i can taste is your sweetness ' 'line'
UNION
SELECT 'and all i can breath is your life ' 'line'
FOR XML PATH('test'),TYPE).value('(/test)[1]','NVARCHAR(MAX)')
will keep the angle brackets, but it is once again, an NVARVCHAR field...
much of an interest, but doesn't help me because I have a large nested XML PATH query.. :(
XSLT8690: XSLT processing failed and all HTML are displayed as mere text
You checked for the encoding, you checked for the xsl output set to html, and even removed all the comments before the xsl template but still you are getting. All the contents displayed as plain text and when you checked your developer tool,
XSLT8690: XSLT processing failed
And frustrated to take hit on google to find the solution? well, relax because I encountered this once and even wasted almost a week worth of things to do because it works in Chrome, it works in Firefox, it works in Safari, but NOT IE...(8 or 9 too).
If I've done it right, then how come it is displaying properly in other browsers and NOT IT... I understand how you feel..
But the real reason is, you "might" have screwed it a little and those non-IE friends just wouldn't mind about it. Too bad that it will not tell you where did you get wrong (even if you sing out loud.. LOL).
We don't know where it got penalized by IE,so we're asking .NET side where. Using XslCompiledTransform.
It is simple, just instantiate XslCompiledTransform object and pass true in the constructor like this.
sparemyxsl.Load(pathToYourStyleSheet);
Even if this stylesheet is using include or import, once you invoked the Load method, it will process all related XSL stylesheets, merge it and check what's going on. It will throw an exception when it finds something bad.
On my experience, I accidentally added an extra line of include that also refers to the same xsl file. It is a good start. (^_^). I hope you can find the fault part.
and don't forget the namespace for XslCompiledTransform
System.Xml;
System.Xml.Xsl;
Few basic things to speed up transition learning in XSLT
Holiday sure is short (although it was a 3 day holiday), especially if we can just realize that we got lots of things to do...
I was able to work on my XSLT templates, and saw how I wrote them few months ago. I even laughed when I saw that I did a horrible for-each block, that can be solved by using the concat function, or even simpler than enlosing things between a curly brace (in case of attributes).
It improved a lot, way cleaner than it was before and more "straight-to-the-point", if you know what I mean. we can just directly write the templates as if we're writing HTMLs, without having to nest xsl:elements and attributes..
Substring function in XSLT
And they just didn't make it something like javascript... I'm never expected that XSLT has function like this, and it just helped me in one of my XML/XSL parsing task.
substring("ABCDEFG",3,3) will display CDE since XSLT doesn't refer the first element on 0 index.
Actually, I really disliked the way XSLT do in loops. you can't overwrite variables, and for-looping and performing something on a node-specific basis is really painful, you have to do it the HARD way, which makes your coding experience a bit dirty, especially if you are already attached to the OOP way of doing things...
XSLT was never meant to be a programming language anyway.. .
substring("ABCDEFG",3,3) will display CDE since XSLT doesn't refer the first element on 0 index.
Actually, I really disliked the way XSLT do in loops. you can't overwrite variables, and for-looping and performing something on a node-specific basis is really painful, you have to do it the HARD way, which makes your coding experience a bit dirty, especially if you are already attached to the OOP way of doing things...
XSLT was never meant to be a programming language anyway.. .
Get XML results for your Query (SQL 2008)
I'm still find it hard to squeeze all available optimization on my site. I successfully had facebook plugins in it after trying, and now I'm staring at the SQL Server database, which can be a potential bottleneck to my web app.
So, maybe it would be nice if I can simply get my query as XML and pass it directly to be rendered. This will eliminate additional mappings and will free me some rendering process too, which is sweet! ^_^
So, how to do it? Very simple...just use "FOR", "XML PATH" and TYPE
so, in this sample query...
SELECT 'TEST Title' as title
,'SAMPLE Description' as [description]
FOR
XML PATH(''),
TYPE
will produce
<title>TEST Title</title>
<description >SAMPLE Description </description >
Simply replace the hard-coded string to column-names and you're making XML queries in no time. So, instead of mapping everything to some object/classes, I'll have this coupled by the presenter page to the view. Now, the only problem I have is to wait for weekends to continue doing my xslt site.
So, maybe it would be nice if I can simply get my query as XML and pass it directly to be rendered. This will eliminate additional mappings and will free me some rendering process too, which is sweet! ^_^
So, how to do it? Very simple...just use "FOR", "XML PATH" and TYPE
so, in this sample query...
SELECT 'TEST Title' as title
,'SAMPLE Description' as [description]
FOR
XML PATH(''),
TYPE
will produce
<title>TEST Title</title>
<description >SAMPLE Description </description >
Simply replace the hard-coded string to column-names and you're making XML queries in no time. So, instead of mapping everything to some object/classes, I'll have this coupled by the presenter page to the view. Now, the only problem I have is to wait for weekends to continue doing my xslt site.
Problem with IE
On my recent web development, I've decided to implement XML+XSLT to save some server processing to render HTML contents. Also, I'm considering this for future maintenance, if ever I would need to change the layout, I'll simply change the XSL templates.The next time xml pages are loaded using that XSL transform file, the browser will not download it anymore and simply apply the transform locally. This also has the benefit of making information reusable. Since the information is already available as an XML document, anyone can simply make a Webrequest to a page URL, convert the stream into an XmlDocument, and information is there. I also decided to monitor all file request on my website. This is to get all site activity as much as possible,and make it invisible to user without specifying additional variables (session, querystring, form, viewstate or cookie).
I've tested this on FF, Chrome and IE9. Got it working, but when I tried it on IE 8, it made me sad that IE8 strips UrlReferrer of XSLT file. (other files do have their UrlReferer btw).
I can't make a big step to decide and assume that all visitors of my site won't be using IE8 or below. I think IE is still the most used browser, and it was already a fact. And another depressing fact is that, to install Internet Explorer 9, you need to upgrade to a more recent version of Windows *cough* 7. Yes,
IE9 is only available to Windows 7.
Now, this has been an issue with Web Developers. Flash or Javascript? How many users would install or upgrade their Flash version just to have everything on your website rendering OK? I don't want to think that, I can have few visitors to install Windows 7 for me and have them use IE9.
Using MVP Pattern + XSLT
I just finished developing my web framework in MVP and now, it is time to do work on the client side. XSLT made the missing piece I want for my website complete. Using this, data will be presented in pure XML, which means datas on the website can be easily re-used on different platforms, and even javascript too, which is nice.
This doesn't limit my site to just have a passive view. I can still have all those input fields and accept all those user input datas, yet my site will be in XML form, web crawlers can easily see my site, no unnecessary SEO paranoia things, hehe.
All this facts leaves me to one last task, mapping each request in IIS to make those URLs pretty to search engines.
UPDATE:
I tried some dynamic XSLT approach, Chrome is OK, IE is OK (even 6.0), but FF (3.5 and 4.0)gives an error... I think I need to make a good re-write rule to trick FF that the xsl file referenced is a static one.
This doesn't limit my site to just have a passive view. I can still have all those input fields and accept all those user input datas, yet my site will be in XML form, web crawlers can easily see my site, no unnecessary SEO paranoia things, hehe.
All this facts leaves me to one last task, mapping each request in IIS to make those URLs pretty to search engines.
UPDATE:
I tried some dynamic XSLT approach, Chrome is OK, IE is OK (even 6.0), but FF (3.5 and 4.0)gives an error... I think I need to make a good re-write rule to trick FF that the xsl file referenced is a static one.
Subscribe to:
Posts (Atom)

