Problem solve Get help with specific problems with your technologies, process and projects.

In an XSL stylesheet, how can I retrieve information from an extermal XML file?

In an XSL stylesheet, is there an available function or method that would return the number of a particular element from an XML file that could be used as a parameter in the transformation?
You can use the document() function in XSLT to load an external file. The result of the function is the root document of the file passed as the parameter, so you can use XPath to retrieve whatever information you want from it, for example:
<stylesheet version="1.0" xmlns="https://www.w3.org/1999/XSL/Transform">
	<variable name="external" 
		select="document('data.xml')//titles[title_id='BU2075']" />
	<template match="/">
		<copy-of select="$external" />

Dig Deeper on Win Development Resources

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.