xml


value-of select=“document($path)/ns0:element1/ns0:element2” returns NULL with SAXON-B XSLT 2.0 (saxon9)


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><?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><?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>
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.

Related Links

How to get the longest path of XPath-query contained in XML?
XML comments and Delphi XMl Data Binding
Check a specific node value with SimpleXMLElement :: xpath
Can XSD define a wildcard complex type?
Create dynamic variable name in XSLT or how can you solve this problem?
What does get read from an nonexistent XML tag read by Action Script 3?
XML / SQLITE DB for use on a CD
Pulling out XML attribute information in Scala
How do I output xml with ASP.NET razor?
IE, XML, zone security, XMLhttprequest
APIGEE — generate documentation from XML wadl?
XPath - trim and starts-with together (cut of whitespaces)
Is an xml attribute without a value, valid?
How do we integrate Saxon with Visual Studio?
XML Insert attribute
How can I sum-up the results of a for-each loop in XSL?

Categories

HOME
grok
github-for-windows
interface
sitecore
alarm
opendj
jax-ws
pcl-crypto
stellar.js
speech-synthesis
intercom
selenium-ide
gource
package-managers
video-editing
imessage
lilypond
simpleitk
libigl
pagespeed
joptionpane
definitelytyped
corpus
flooding
has-and-belongs-to-many
progress-bar
errbot
bioinformatics
magento-1.8
scrollview
database-comparison
erb
android-gridview
wurfl
timing
demo
trigonometry
softmax
linqpad
apache-directory
apache-spark-dataset
mesosphere
twilio-click-to-call
tf
lightning
payara-micro
video-conferencing
appdomain
subnet
headless
pdf-conversion
java-websocket
objectscript
vibrate
swingworker
xcode-server
macaulay2
stream-processing
angular-ui-typeahead
tracker-enabled-dbcontext
dbamp
halcon
vhosts
intel-c++
rubaxa-sortable
text-search
lasso
atoi
amiga
dnssec
google-refine
nutiteq
bufferedinputstream
cakephp-2.7
crowd
sonarqube-5.0
metatrader5
angular-carousel
parallel-testing
accesscontrolexception
xmltodict
solace-mq
http-patch
neos-server
alice
midlet
fusefabric
azman
virtualpathprovider
webdev.webserver
cgbitmapcontextcreate
uipagecontrol
inline-formset
vs-android
folding
zend-rest
data-mapping
alsb
ifilter

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App