How can I dynamically specify the href value in the line
<?xml-stylesheet type="text/xsl" href="first.xsl"?>
in an xml?
I would like to substitute "first.xsl" dynamically.
Thanks for your help. ================== Apologies for messing this up/making it difficult for you to help ====
My XML is:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="first.xsl"?>
<WinData records="1" fields="4">
<record id="1">
<Name type="82">January</Name>
<Dept type="323">19</Dept>
<InceptionDate type="82">01/01/2010</InceptionDate>
<Salary type="645">3729.71</Salary>
</record>
<!-- Created from D:\AJAY\C#\VS2010\SBWA\XML -->
</WinData>
The XSL is:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Sub Selection of Data</h2>
<table border="0">
<tr bgcolor="#9acd32">
<th>Name</th>
<th>Dept</th>
<th>InceptionDate</th>
<th>Salary</th>
</tr>
<xsl:for-each select="WinData/record" >
<xsl:sort select="./Name"/>
<xsl:sort select="./Dept"/>
<xsl:if test="Salary>100">
<tr>
<td><xsl:value-of select="Name"/></td>
<td><xsl:value-of select="Dept"/></td>
<td><xsl:value-of select="InceptionDate"/></td>
<td><xsl:value-of select="Salary"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
My specific issues/objectives:
- How can I incorporate the code snippet offerred by iHeartGreek?
- Is there a way to pass the 'replacement' xsl (newLink.xsl in the snippet) as a parameter?
Two posible solutions.
1) Two pass transformation. You can output a PI like this:
2) Use a "population" pattern (or "fill in blanks", as Dimitre calls), and a metadata URI to get the layout with
fn:document()
. Look this Dynamically decide which XSL stylesheet to useNote: The PI is part of the input tree. Whether this input tree is from a parsed document or built by DOM API or whatever means, for the XSLT processor there is only a "static" node of type "PI" with a "final" string value.
You could use an XSLT document to transform your XML data.
Use: (let's say the node is called "link")