0
votes

The getdetails.xslt code (XSLT 2.0) below reads the contents of user-config.xml via a document().

The code successfully works against Saxon 9.4.0.6 and the value of ns0:project_abs_path is visible in the xml output as shown below

<?xml version = "1.0" encoding = "UTF-8"?>
<xmlString>&lt;?xml version="1.0" encoding="UTF-8"?> C:\myProject</xmlString>

However, the below xml output (NOTE:no value for ns0:project_abs_path) is returned when the same XSLT code is run against SAXON-B XSLT 2.0 (saxon9) in TIBCO Transform Activity.

<?xml version = "1.0" encoding = "UTF-8"?>
<xmlString>&lt;?xml version="1.0" encoding="UTF-8"?></xmlString>

*There is no error returned.

user-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<ns0:userRules xmlns:ns0="http://www.tibco.com/schemas/-bw/SharedResources/Schema.xsd">
    <ns0:project_abs_path>C:\myProject1</ns0:project_abs_path>
</ns0:userRules>

getdetails.xslt

<?xml version='1.0'?>
<xsl:stylesheet version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="http://www.tibco.com/schemas/bw/SharedResources/Schema.xsd" 
xmlns:ns1="http://www.tibco.com/schemas/bw/SharedResources/rule-db.xsd">
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:param name="invar_ruleid"/>
<xsl:variable name="var_installation_path">C:\FOLDER</xsl:variable>
<xsl:variable name="var_user_config_path" select="concat($var_installation_path,'\bin\user-config.xml')"/>
<xsl:variable name="var_project_abs_path" select="document($var_user_config_path)/ns0:userRules/ns0:project_abs_path"/>
<xsl:variable name="file">file:///</xsl:variable>
<xsl:variable name="var_out_file_path" select="concat($file,$var_project_abs_path)"/>
<xsl:template match="/">
<xsl:value-of select="document(concat($var_installation_path,'\bin\user-config.xml'))/ns0:userRules/ns0:project_abs_path"/> 
</xsl:template>
</xsl:stylesheet>
1

1 Answers

0
votes

Saying "A NULL is returned" is a very vague. Could you be more explicit? Are you seeing an exception, or a Saxon error message, or incorrect transformation results? If you see an exception, could you show the stack trace? If you see a Saxon error message, could you tell us what it is?

The only thing obviously wrong with your code is that you are constructing a Windows filename (in the form "c:\a\b\c") and passing this to the document() function, which expects a URI. In theory this is always wrong, but some applications tolerate it. You should be passing a URI of the form "file:///c:/a/b/c". I have no idea whether this is the cause of the problem.