Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 11th, 2007, 09:56 PM
Authorized User
 
Join Date: Jun 2006
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.
input1.xml

<fruit>
  <apple>
    <type>royal</type>
    <qty>2</qty>
  </apple>
  <orange>
    <type>sour</type>
  </orange>
</fruit>

in my result
errorlisting.xml


<errors>
  <orange>
    <desc>missing node</desc>
    <file>input1</file>
    <node>2</node>
  </orange>
</errors>

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

thanks


 
Old March 11th, 2007, 09:59 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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)
 
Old March 12th, 2007, 04:32 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





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





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