Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 11th, 2007, 09:56 PM
Authorized User
Join Date: Jun 2006
Location: Sydney, NSW, Australia.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Displaying your source xml filename

Hi there,

is there a built-in function or a way that I could find out the filename of the source xml that i am translating in my XSLT?

To give a context of what I would hope to achieve is ..... I am translating a bunch of XML files, one after another. In my xslt, I perform various node test and if nodes are missing, I would like to create an error node that provides information about the parent node of the missing node. this information would be the position of the parent node and the filename that this error occured.

for eg.


in my result

    <desc>missing node</desc>

so, is there a way i can find out the source xml filename?


Reply With Quote
  #2 (permalink)  
Old March 11th, 2007, 09:59 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

There is no built-in way of doing this in version 1.0. The standard workaround is to have a global parameter such as sourceUri which you set before doing the transform. How you do that depends on which processor you are using.


Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old March 12th, 2007, 04:32 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

XSLT 2.0 has the function document-uri(). In XSLT 1.0, the usual solution is to pass the source filename as a parameter to the stylesheet.

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Source Xml into Target Xml Using XSL. alapati.sasi XSLT 3 May 14th, 2007 10:54 AM
displaying XML forlorn Classic ASP XML 0 August 19th, 2005 03:16 AM
Consuming and displaying XML busher XML 5 July 12th, 2005 12:08 PM
accessing an XML file with Filename in a var c# Jkelly BOOK: Professional Crystal Reports for VS.NET 0 August 16th, 2004 04:00 AM
Filename of xml in xslt? surfer97301 XSLT 2 July 4th, 2003 02:56 AM

All times are GMT -4. The time now is 01:18 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.