I'm new at XSLT. I want to create a hyperlink using XSLT. Should look like this:
Document
Document is the link and upon clicking this, download of a file should begin.
Any ideas? :)
Thanks
There's no such thing as a hyperlink in XSLT or XML. If you're generating HTML with your XSLT, then you just need to output the appropriate elements and attributes, which you can do literally if you want, e.g.
<xsl:template match="somethingthatgeneratesalink">
This is a link to example.com
</xsl:template>
Related
I am writing XSLT to be used with XML in Aspose.PDF to generate the PDF, how do I insert the page break in the Aspose.PDF XSLT?
I have tried #$NP but it doesn't seem to be working, or my syntax is not correct.
<TextFragment>
<TextSegment>#$NP</TextSegment>
</TextFragment>
I have also tried to split the document by having a multiple page tags.
<Page>...</Page>
But that also didn't seem to work, and Aspose was actually throwing an error when I tried that, so what would be the correct way?
I would like to be able to insert the page break after each section of the PDF. Also any links to some advanced Aspose.PDF XSLT examples will be appreciated.
For the old Aspose.PDF versions, please, try this way:
<Text>
<Segment>
<!--Page Breaker-->
#$NP
</Segment>
</Text>
For the latest Aspose.PDF versions, please, try this way:
<Page>
<TextFragment>
<TextSegment>
First page.
</TextSegment>
</TextFragment>
</Page>
<Page>
<TextFragment>
<TextSegment>
Second page.
</TextSegment>
</TextFragment>
</Page>
Hope it helps. Otherwise, feel free to ask me.
Note: I am working as Developer Evangelist at Aspose.
I loaded an XML file via the "Import XML definition" and everything worked fine. But the XML needs the following added to it
Here is my question,
I just have the XML but not the xsd.
How do I add the xmlns and xsi string into the root node?
For the elements, how do I add the tag like 'common' and 'udf' before the column name like common:abbreviation or udf:name or udf:value?
Basically is there an easy and quick way to do this? Do I need to reimport the files with new xsd?
Thanks
<MyRoot
xmlns:udf="http://www.url.com/xx/XXXX/type1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:common="http://www.url.com/xx/XXXX/common"
xmlns="http://www.url.com/ws/v410/NewPerson"
xsi:schemaLocation="http://www.url.com/xx/XXXX/NewPerson NewPerson.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<common:ID>NNNNNNNNNN</common:ID>
<UDF>
<udf:name>Name Content</udf:name>
<udf:value></udf:value>
</UDF>
</MyRoot>
I've written a post about adding ports to XML transformation. See if this helps: http://powercenternotes.blogspot.com/2013/03/adding-port-to-existing-xml-parser.html
I'm trying to get content from another XML file in the same directory as my XML file. However, I don't know how to get the uri of the source XML. The XSLT keeps relating to its own directory.
How can I get the URI of the source XML?
I would recommend document-uri() rather than base-uri(). It will usually be the same, but base-uri() is affected by the xml:base attribute and by use of XML external entities, while document-uri() is not.
You can use the base-uri() function:
<!-- your external XML -->
<xsl:variable name="doc" select="document('http://www.xyz.com./path/your-doc.xml')"/>
<!-- the base URI of your external XML -->
<xsl:variable name="doc-base-uri" select="base-uri($doc)"/>
I found an answer that worked for me.
I got it using base-uri(.).
I need a way to transform XML to HTML (using XSL) but without a server. So, I want to create a standalone HTML file (with hardcodes XSL path and name).
Allow the user to select an XML
Transform it with the XSL and display results in browser
Original XML cannot be changed (so cannot just embed XSL in XML)
Is this possible? Everything I found requires post, but I'm not using a server
Regards
Mark
Yes, it's possible. And you don't need javascript to do it, but you can use javascript if you want.
Just look at the previous (XSLT question)[https://stackoverflow.com/questions/12964917]
Use a processing-instruction like...
<?xml-stylesheet type="text/xsl" href="soccer.xslt"?>
Refer:
Direct linkage through pi: http://www.w3.org/TR/xml-stylesheet/
Transform through javascript:
http://dev.ektron.com/kb_article.aspx?id=482
Calling XSLT from javascript
I have 3 XSL files which have paths in them to something like C:\templates\Test\file.pdf
This path isn't always going to be the same and rather than having it hard coded in the XSL, I'd like it so that the path C:\templates\test\ is replaced with a tag [BASEPATH] and when I read in the xsl file into the XSLTransform object (yes I know it's been deprecated, I may move over to the XSLCompiledTransform at the same time), I'd like the tag [BASEPATH] to be replaced with the absolute file path of the web folder (or Server.MapPath("~") seeing as it is in .net)
I thought I may be able to make an XSLLoader aspx page which takes the name of the XSL file through the querystring and then returns the XSL file via xml content-type. When I try this, I get a 503 error though so I'm not sure if you can pass urls like this into the XSLTransform.Load method.
Any ideas what to do?
Have you looked at XSL parameters?
<xsl:param name="basepath" select="'C:\Users\Graeme\'" />
<xsl:value-of select="document(concat($basepath, 'test.pdf'))" />
Then, most decent XSLT engines have a way to set a root level parameter from outside.