First a short task description:
There is an XML file which references a xsl stylesheet which is within a *.dll.
The beginning of this XML looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='res://name_xsl.dll/frameset.xsl'?>
This xml file can be opened and displayed as an HTML within Internet Explorer and only IE.
(The xsl transform the xml to html)
As you can see it references the win32 system folder, in which the dll file is saved.
Referencing with "res://" does work.
But now I do not want to store my dll within the system folder, but under a different folder lets say %ALLUSERSPROFILE% (environment variable) which e.g. on Windows XP is C:\Documents and Settings\All Users or on Win7 C:\Users\Public (Not sure about that one).
How do I reference to the dll lying in that folder?
Is it possible to do this using environment variables, such that it is system independent?
What solution would you recommend.
(All html, xsl data is saved locally within the dll on the local computer.)
So far I have tried to change the reference line to the following:
<?xml-stylesheet type='text/xsl' href='file:///c:/Documents and Settings/All Users/name_xsl.dll/frameset.xsl'?>
I have also tried the same with the root folder c: and even without absolute path having all files (xml and dll) in the same folder.
All attempts without res:// resulted in the following error message:
The system cannot locate the resource specified.
Error processing resource 'file:///C:/Documents and Settings/All Users/name_xsl.dll/...
or 'file:///C:/name_xsl.dll/frameset.xsl'
Could you help me out? Why it does not find the file?
(filenames are fictive)
This is the solution:
<?xml-stylesheet type='text/xsl' href='res://C:%5CDocuments and Settings%5CAll Users%5Cname_xsl.dll/frameset.xsl'?>
Notes:
You MUST use the res:// protocol to access a resource within a file.
File system backslashes can be encoded as %5C . Possibly forward slashes will work as well.
Example:
I tested this example for the file:// protocol, but it should work the same way as the res: protocol. On my system, I have a text file located at:
C:\Program Files\CodeGear\Delphi for PHP\2.0\privacy.txt
I can access this file, by putting into the nav bar of the Windows File Explorer:
file:///%ProgramFiles%/CodeGear/Delphi for PHP/2.0/privacy.txt
Notice backslashes converted to forward slashes, and no need to escape spaces. This has been tested and it works. The equivalent on the res protocol had not been tested, but it should work the same way, except of course that the res protocol is slightly different in that it also includes a resource index number.
Refer http://msdn.microsoft.com/en-us/library/ie/aa767740(v=vs.85).aspx for syntax.
Related
I have a compiled assembly (dll) and a corresponding xml document (generated by DoxyGen, I think?). How can I convince MonoDevelop to take me to the definitions within the xml document instead of the Assembly Browser when I use Go To Definition?
I've tried putting the xml file in the same folder as the dll, but that doesn't seem to be enough, and the MonoDevelop documentation doesn't seem to mention this at all.
I have a directory structure, containing a list of directories and files.
I want to give user an option of downloading a file. For downloading, I'm using HTML5 download attribute. It works perfectly.
But the directory structure i have can have dotfiles too, examples: .babelrc, .gitignore, .eslintrc, etc.
When I use the same technique to download such files, file is being downloaded with the same content but the file is no longer a dotfile. After downloading, let's say .gitignore, the file becomes gitignore.txt.
I'm using this for my project github-plus - Chrome extension to display size of each file, download link and an option of copying it's contents.
Any help would be highly appreciated.
I'm using this format:
Download
JSFIDDLE DEMO
Quoting HTML5 specification on downloading resources with the download attribute, about file type/extension :
If the claimed type is known, then alter filename to add an extension corresponding to claimed type.
Otherwise, if named type is known to be potentially dangerous (e.g. it will be treated by the platform conventions as a native executable, shell script, HTML application, or executable-macro-capable document) then optionally alter filename to add a known-safe extension (e.g. ".txt").
It seems that:
the part of the algorithm that finally choses the filename is platform-dependent
if the extension is not recognised, as in the case of dotfiles, the browser will try to determine it by using the file MIME type
dotfiles might be considered anyway as potentially harmful as they are hidden files on various platforms. This seems to be what happens in your case, with the initial dot being removed and the .txt extension appended.
I have a process to generate html file dynamically, but i dont want to place those html files under the webapp, because if the project are re-deployed, I have to deal with the existing html files(copy out and copy in).
So I'm just wondering if I can place the html files outside of the webapp.
If not, is there any other proper way to meet the requriement?
I'm using tomcat.
Appropriate your help.
Create below dir if not exist:
${CATALINA_HOME}/conf/Catalina/localhost
Create a xml file "article.xml", place the xml under the above path as follows.
${CATALINA_HOME}/conf/Catalina/localhost/article.xml
Add below content to the xml.
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/article" docBase="C:/apps/blog/article" debug="0"
reloadable="true" privileged="true">
</Context>
Start tomcat.
If there's aa.html under the C:/apps/blog/article, use http://localhost:8080/article/aa.html to access the html.
NOTE:
1. Tomcat will take the xml as an web application, and load the resource configed in the xml.
2. No need to create WEB-INF and META-INF for the external folder(C:/apps/blog/article here).
I have a folder of several hundred XML files that I would like to convert into a folder of HTML files. I've created an XSLT that works in w3schools.com's XSLT tester, but I'm not sure how to apply that stylesheet across hundreds of XML documents. My XML looks like this (and the only nodes I'm interested in are title, author, and lyrics):
<?xml version='1.0' encoding='utf-8'?>
<song xmlns="http://openlyrics.info/namespace/2009/song" version="0.8" createdIn="OpenLP 2.0.1" modifiedIn="OpenLP 2.0.1" modifiedDate="2012-03-14T02:21:52">
<properties>
<titles>
<title>Amazing Grace</title>
</titles>
<authors>
<author>John Newton</author>
</authors>
</properties>
<lyrics>
<verse name="v1">
<lines>Amazing grace, how sweet the sound<br/>That saved a wretch like me<br/>I once was lost, but now am found<br/>Was blind but now I see</lines>
</verse>
A couple questions about this:
1) Might it be better to use XQuery since I'm only interested in extracting a few lines per XML file?
2) Regardless of XSLT/XQuery, how can I implement a solution that converts a folder of XML files (without manually editing each one to call upon the XSL stylesheet)? I'm running OS X 10.8.4.
Thanks in advance.
Just write your own shell script using the xsltproc command. This is what I used successfully for XSLT batch processing.
Or just open a shell, cd to the folder with the XML files and then enter the following two commands:
mkdir results
xsltproc -o results/ path/to/stylesheet.xslt *.xml
I think XQuery would be more convenient if you had all of your XML in a database, but on the filesystem XSLT may be simpler.
I would just use Saxon-PE, and invoke it from a shell script. You could also use Automator.
I've been given the task of rendering an xml file via xsl as html. This means it appears as /.../index.xml in the URL.
However, the task requests that the xml file renders in the URL at /.../index.html.
Currently it renders as index.xml not .html - how do I achieve this?
Any ideas/resources would be great, thanks.
One simple way to satisfy the requirement (there are others, no doubt) is to configure your server to redirect index.html to index.xml. How you do that depends on which Web server you are using; consult the documentation for your server. If you're using Apache, you will want to read up on .htaccess files and redirection.