I have an defined xslt(in my old project) and I have an output file format genrated from this xslt , Now can we know the structure or input xml with these files?
XSLT 1.0: Pass the filename in via a parameter.
XSLT 2.0: Use XPath 2.0 function base-uri().
Related
I am trying to convert Mapper activity of TIBCO BW into a separate XSLT i.e. removing the whole code and using XSLT in place of that.
IS there any easy and fast way to do this as long xslt files are hard to validate.
While in the mapper (select of field), type ctrl-c (copy).
Use ctrl-v (paste) in any text editor to get the XSLT file equivalent.
For use of this XSLT in BusinessWorks, you can use a XSLT Transformation and include either the text itself (in input) or link the file.
See page 322 in the Palette documentation.
I have a xsl 2.0 stylsheet which uses xsl 2.0 specific enhancements. I am now trying to move templates in xsl 1.0 as I have some restrictions in using xsl2.0. When I am running my xsl 1.0 templates I am getting some encoding related errors.
I wanted to understand what is the equivalent of use-character-maps in xsl 1.0.
Thanks
Character maps are a new feature in XSLT 2.0, there is no equivalent feature in XSLT 1.0. However if you want to output a certain entity or character reference in XSLT 1.0 then disable-output-escaping as in e.g.
<xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text>
might suffice, as long as the transformation result is serialized. In fact, disable-output-escaping use is a feature in XSLT 1.0 supposed to be replaced by character map use in XSLT 2.0.
If you are getting "encoding related errors" then it might be worth finding and eliminating the root cause of those errors, rather than trying patch around them with character maps or disable-output-escaping.
i have a xsl file which is containing some contents for displaying.This contents gets changed often. so each time have to modify the xsl file.
So thought of moving the content to a text ot properties file so that just changing this will be fine.
can anybody tell me how to move just the contents to a text file and access it using xsl file.
Thanks in advance.
Why use a text file? Surely XML would be better?
An XSLT stylesheet can read a second input document using document('strings.xml'). Then you can access strings as for example
<xsl:value-of select="document('strings.xml')//string[#id='msg012']"/>
where the file has a format like
<strings>
<string id='msg012'>This is one of the strings to include</string>
</strings>
In XSLT 2.0 you can wrap the access logic into a function so the call just becomes
<xsl:value-of select="my:string('msg012')"/>
The XML file name is specific but I need to build a dynamic path. I have tried using a variable to build the path but it didn't work:
<xsl:variable name="path">
...conditional code
</xsl:variable> <xsl:value-of select="document('myXML.xml')/worksheets/$path"/>
2.0 solutions ok.
Evaluation of any dynamically-generated XPath expression is not supported by the XSLT 1.0 or XSLT 2.0 standards. It will be supported in XSLT 2.1.
If the dynamically-generated XPath expression is not too complex, the technique in this answer can be used successfully:
Retrieving XML node from a path specified in an attribute value of another node
You need an extension function, XPath 2.0 does not support dynamic compilation/evaluation. Saxon has saxon:evaluate. Even if your processor does not support such function you might be able to implement it yourself as an extension function.
How can I get the file name using xsl 1.0?
I tried
<xsl:value-of select="base-uri()" />
but got "Fatal Error! Could not find function: base-uri"
base-uri() is a standard XPath 2.0 function, so when running XSLT 1.0 this function will be unavailable.
In XSLT 1.0 the filename (of what?) may be passed as a parameter for the transformation.
Do note that it isn't always possible to produce a filename for a stylesheet or for an XML document -- either or both may be residing in memory without an associated file.
It is not clear from the problem which filename must be produced.
Here is how to find filenames in XPath 2.0 / XSLT 2.0:
The filename of the current document:
base-uri()
The filename of the current stylesheet module:
base-uri(document(''))
There is no such XPath function, or XSLT extension to XPath function to do this in XSLT v1/XPath v1.
It is quite possible for there to be no file, and even if there is no reason for the XSLT engine to have that file name (consider loading the file content into a buffer, parsing the buffer into a DOM and then passing the DOM to the XSLT processor).
You will need to pass the filename into the processor to be available as a parameter in the transform.