I have an XML file which is rendered by a set XSL file (XSLT 1.0). The XSL file includes several other XSL files with multiple templates in them.
What I need to do is include a button in the rendered XML to open the same XML in a new window, using some different templates in the XSLs.
Including the button and opening a new window is not the problem, but how do I tell the XSL to use different templates because it got opened in a new window? My idea was to use JavaScript for opening the new window, but I don't see how I could set or pass a parameter to check on with XSLT/XPATH.
Thanks in advance for your help!
Change the xml or transform server side (with php,asp,jsp...) or client side (with javascript). You can parameterize only the xsl processor, but not the xml file. If you don't want to use xsl processor, then you have to recreate the xml file on server side with same body and different header with another stylesheet.
I did it by using querystrings.
Upon loading opening my URL in a new window
window.open(window.location+'?a=1')
in the JS onload event I check if the querystring is empty
if(window.location.search=='')
if not I search for the links by class and remove the attributes
.removeAttribute('href');
.removeAttribute('onclick');
To clarify, the templates would simply have removed some links from the page. It was easier to simply remove them by JS than using different templates.
Related
i want to display pdf files in my website but unfortunately it will automatically download by idm.
here's my code:
$
<div class="viewerthesispdf">
<div id="viewer" class="pdf-viewer" data-url="<?php the_field('upload_pdfACField'); ?>"></div>
data-url is used to embed a file in a web page. That makes sense for images. It doesn't make sense for a PDF (or Excel or Word or most other file types) because normally these types of files are in place of a page, not a section of a web page. There are generally two solutions, depending on whether the files need to be restricted:
Use an href tag to reference the file. Download File1 I usually include target="_blank" in order to force a new page so that if there is a problem with the download you don't "lose" the original page, but it isn't strictly necessary. This will simply give a link to the file - and you can use a button, Font Awesome, images, etc. to make it fancier - but in the end "a link to a file".
Create a form which returns only the PDF as a result. Again I usually include target="_blank". The advantage of a form is that (a) the file doesn't have to actually exist on disk - it can be created by a script on-the-fly (technically this can be done with a link too - but typically a link would be a file rather than a script) and (b) you can include any necessary parameters for security, user-specific customization, etc. as part of the form. The form can use a GET or a POST depending on your preference.
Use href to show your pdf file list like this Filename , it will not start downloading automatically, only when user click on it, it will start download.
I have a dynamic pdf file which needs to be filled programmatically. I am using itext libraries to do so. Below are the steps I followed.
Extract the dynamic pdf and get the data xml file.
Fill the xml data file.
Call the itext apis to generate new pdf by passing the template pdf and xml data file.
The issue I face is if there is a repeater inside the container (which has a close button) in the template pdf, its not copied into the generated interactive pdf file. None of the javascript functionalities are triggered when creating the new pdf and because of which some of the fields become read only.
Is it possible to trigger the javascript in the pdf while generating the new pdf or while opening the new pdf?
Much appreciate any help.
I am trying to use webview element in a universal app using javascript. My aim is to browse some websites adding some content of my own to its html document.
First, I set src attribute of webview to www.example.com and it browses the site. This was just to make sure the webview is capable of browsing the site.
Next, I tried getting the html and load it to webview using navigateToString method like this:
$.get(url, function (data) {
webView.navigateToString(data);
});
This causes the page to be loaded out of shape (aperarently some .js or .css files are not loaded or blocked from running), or it isn't even loaded.
I wonder what is the difference loading the page by its url and loading its html by manually like this. And is there a workaround I can overcome this problem.
Note: I'm new at both js and html.
A web page is usually not made of a single HTML file. In order to make it work, you will have to retrieve not only the HTML but also the javascript and the css files.
This can be a tedious work.
If you are trying to open something from the web, the easiest way is to perform a regular navigate() which will take the URI as parameter and perform a "full" browse (as the browser will do). The retrieval/loading of the CSS/JS will be done for you.
If you want to open a local page (local to your application), navigateToString() is a good path but you will have to host locally all the page dependencies (css/js fiels) or embed all the style and code in the HTML page itself.
I have an application that will check if a javascript file exists on our CDN and I would like to display the contents of that file in the browser window. I have all the nuts and bolts figured out, I just need to display the contents of the javascript file when I put in the URL where it exists.
Thanks in advance.
I believe you can output a javascript file to a webpage by just making sure any html elements are escaped. You can use the htmleditformat() function to do this when you output the value.
For example:
<cfhttp url="#jsurl#" />
<cfoutput><pre>#htmleditformat(cfhttp.filecontent)#</pre></cfoutput>
Other options just using the js address directly are to 1) link to the js file if you just want to be able to see it in the window, or 2) show the js file in an iframe
I'm not quite sure what you're asking:
"I need to open a javascript file in a web browser"
A. this is OS dependant, you call the binary that's registered for .htm files with parameters pointing it's initial destination to that .js file.
"I have a web app and want to dynamically display the contents of remote files formatted as text"
A. Use a block and fill it with GetWebResourceUrl().
"I am writing a standalone app and want to display remote files as text"
A. If you are writing a standalone, why do you want to display the contents of a js file via a browser? Use your local API, or launch the default text viewer with a local temp copy.
I was wondering if this is possible, I'm not looking for code, i just want to be pointed in the right direction - php, asp or javascript. I have an xml file:
<?xml version="1.0" encoding="utf-8"?>
<Groups>
<Group>
<groupNum></groupNum>
<purgeGroup></purgeGroup>
<DupeRecs>
<DupeRec>
<Name></Name>
<Duplicate></Duplicate>
</DupeRec>
<DupeRec>
<Name></Name>
<Duplicate></Duplicate>
</DupeRec>
</DupeRecs>
</Group>
</Groups>
I would like to be able to load this into a web page and have the Duplicate tag display as a checkbox the user can the check/uncheck whether the record is a duplicate and this is written back to the xml file
Broadly, Here are the steps I would suggest :
"Deserialize" the XML into a corresponding object
Display the editable fields in a HTML form on your Web Page
Process the HTML Form action and update your "Deserialized" object.
"Serialize" the result back into the XML file.
You have to take care of multiple edits on the file using some locking mechanism.
I think the best way would be to while parsing the XML file for display, save it into certain variables that can be easily edited, and set these to the new variables for your XML file. When you have everything how you want it in the variables, re-assemble it and use the fopen(), fwrite() and fclose() commands to re-write the whole file.
EDIT: You could also look into PHP's XMLWriter functions.
I'm not sure what you mean by "load this into a webpage" but to have the Duplicate tag display as a checkbox suggests you want to convert the XML to a UI, for this I'd recommend XSLT which can be used to convert XML to anything including ASPX, PHP or JavaScript.
As for writing this back to the XML again I don't know where the XML file is but it is likely you want to send the user response back to the server somehow and that could be done in many ways.
In conclusion if your XML content is on the server then use XSLT to create a web page to display the UI and send the data back to the server.
If your XML content is client side then try Silverlight.