I have a string of XML that I need to pass to a third-party user. We have an xml-stylesheet directive in our XML, but this stylesheet is located behind our firewall. I initially just removed that directive before passing the string to our user. However,
they want to be able to open the XML file remotely, while using our stylesheet. I put a copy of the stylesheet online and can open that with no problem. Unfortunately, I am not sure how the new directive should be written since the stylesheet is now an absolute
path and not a relative one. I tried just replacing the href to be the hyperlink of our stylesheet, but this is not working. In fact, the XML now will not render as XML in a browser when this directive is included. Is there some other way to write this
directive for a hyperlink? This is what I currently have:
We are storing an xml file and I am retrieving the contents of it in my code. Due to size and privacy issues, I cut out all the content, but the important part of the xml is as follows:
We are required to allow certain users to view this file online. Since the XSL address is relative to the file, there is no problem with using an XML control and passing in both the XSL address as the TransformSource and the XML string as the DocumentContent.
However, we are also required to allow users to download the XML content to a file. Obviously, using a relative address of the XSL file is not going to work. We put the XSL file at a specific address (http://www.ourwebsite.com/stylesheets/ourstylesheet.xsl)
which I can view online. I was hoping to change the stylesheet directive to reference this address so that our users could download the XML, but still view it as a document instead of as just data.
If I remove the directive completely, the downloaded document opens in IE as well-formed XML. If I include any directive, it opens in IE as the contents of the XML elements, as I show a small piece below:
Our Dev Care Center Continuity of Care Document123 main street
Is there any way to include the stylesheet as an absolute address, available for anyone, that will actually transform the document?
Not really. I would rather they just be able to open the XML file so that it displays using the stylesheet. I could have them download both pieces, I suppose, but this is for users who are not very technical. I can't create an HTML file for them because
the requirement is that they actually have the data in XML format in case they need to upload it into their database through some third-party application.
Yes, I have an XSLT file, which is what is referenced in the stylesheet directive. It is referenced with a relative address (CCD.xsl) in the original XML document and referenced with a url (http://www.ourwebsite.com/stylesheets/ourstylesheet.xsl)
in the XML document that is downloaded by the users. It works just fine with the relative address on our domain, but the XSL file location is behind our firewall. As a result, if the users download the XML file, they are unable to access the XSL file to
display the XML in human-readable form. Using a url for the href attribute in the stylesheet directive does not seem to be working.
Based on information in another
forum, it appears that only Firefox allows using remote stylesheets. So, we will have to use a different approach on this. Thanks for your help!
Christy Piff...
Member
27 Points
17 Posts
xml-stylesheet directive
Nov 05, 2012 08:28 PM|LINK
I have a string of XML that I need to pass to a third-party user. We have an xml-stylesheet directive in our XML, but this stylesheet is located behind our firewall. I initially just removed that directive before passing the string to our user. However, they want to be able to open the XML file remotely, while using our stylesheet. I put a copy of the stylesheet online and can open that with no problem. Unfortunately, I am not sure how the new directive should be written since the stylesheet is now an absolute path and not a relative one. I tried just replacing the href to be the hyperlink of our stylesheet, but this is not working. In fact, the XML now will not render as XML in a browser when this directive is included. Is there some other way to write this directive for a hyperlink? This is what I currently have:
Thanks in advance for your help!!
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: xml-stylesheet directive
Nov 06, 2012 11:26 AM|LINK
Hello,
Show us your whole xml contents and your xslt file, then tell us what you actually wanna do?
Christy Piff...
Member
27 Points
17 Posts
Re: xml-stylesheet directive
Nov 06, 2012 03:05 PM|LINK
We are storing an xml file and I am retrieving the contents of it in my code. Due to size and privacy issues, I cut out all the content, but the important part of the xml is as follows:
We are required to allow certain users to view this file online. Since the XSL address is relative to the file, there is no problem with using an XML control and passing in both the XSL address as the TransformSource and the XML string as the DocumentContent. However, we are also required to allow users to download the XML content to a file. Obviously, using a relative address of the XSL file is not going to work. We put the XSL file at a specific address (http://www.ourwebsite.com/stylesheets/ourstylesheet.xsl) which I can view online. I was hoping to change the stylesheet directive to reference this address so that our users could download the XML, but still view it as a document instead of as just data.
If I remove the directive completely, the downloaded document opens in IE as well-formed XML. If I include any directive, it opens in IE as the contents of the XML elements, as I show a small piece below:
Our Dev Care Center Continuity of Care Document123 main street
Is there any way to include the stylesheet as an absolute address, available for anyone, that will actually transform the document?
I hope that is a little clearer.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: xml-stylesheet directive
Nov 06, 2012 11:29 PM|LINK
Hi,
Do you mean that you wanna user to open an IE to see the style's defination directly?
Christy Piff...
Member
27 Points
17 Posts
Re: xml-stylesheet directive
Nov 06, 2012 11:35 PM|LINK
Not really. I would rather they just be able to open the XML file so that it displays using the stylesheet. I could have them download both pieces, I suppose, but this is for users who are not very technical. I can't create an HTML file for them because the requirement is that they actually have the data in XML format in case they need to upload it into their database through some third-party application.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: xml-stylesheet directive
Nov 07, 2012 12:14 AM|LINK
Hello again,
This perhaps you need Xslt + xml, maybe you can have a look at the torturial clearly and you know how to do with that:
http://www.w3schools.com/xsl/
Christy Piff...
Member
27 Points
17 Posts
Re: xml-stylesheet directive
Nov 07, 2012 12:48 AM|LINK
Yes, I have an XSLT file, which is what is referenced in the stylesheet directive. It is referenced with a relative address (CCD.xsl) in the original XML document and referenced with a url (http://www.ourwebsite.com/stylesheets/ourstylesheet.xsl) in the XML document that is downloaded by the users. It works just fine with the relative address on our domain, but the XSL file location is behind our firewall. As a result, if the users download the XML file, they are unable to access the XSL file to display the XML in human-readable form. Using a url for the href attribute in the stylesheet directive does not seem to be working.
Christy Piff...
Member
27 Points
17 Posts
Re: xml-stylesheet directive
Nov 07, 2012 07:28 PM|LINK
Based on information in another forum, it appears that only Firefox allows using remote stylesheets. So, we will have to use a different approach on this. Thanks for your help!