XSLT: Creating anchors from outer XML files

Hi,
I'm trying to put the links (href attribute of the <a> element) out of my 
XSLT files, in a XML file, and read it from the stylesheet. I suppose that I 
have to use the document() function to link to the XML file containing the 
URLs, but I don't know how to do it. I've tried something like this:

This is XML file containing the URLs (link.xml):

<?xml version="1.0" encoding="utf-8" ?>
<LINKS>
 <L1>
  /SomePage.aspx
 </L1>
</LINKS>

And this is the code from the stylesheet:

<a href="{document('link.xml')/LINKS/L1}" >
    Some text for the anchor
</a>

But does not work. I've tried to move the XML file in different folders to 
make the things easy... but with no luck.

How this it's supposed to be done?

Thanks for any suggest.
Mario Vazquez



0
alguien (13)
4/24/2006 8:29:54 PM
dotnet.xml 7266 articles. 0 followers. Follow

4 Replies
688 Views

Similar Articles

[PageSpeed] 3

Hi Mario,

That should work. Note that in this case link.xml in resolved relative
to the stylesheet location. If you want it to be resolved relative to
the XML file location then use

<a href="{document('link.xml', .)/LINKS/L1}" >
    Some text for the anchor
</a>

That is you need to pass a node set as a second argument to the
document funtion and that nodeset system Id will be used to resolve the
relative location specified as the first argument.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

0
george5726 (13)
4/25/2006 10:02:57 AM
Mario V�zquez wrote:

> I'm trying to put the links (href attribute of the <a> element) out of my 
> XSLT files, in a XML file, and read it from the stylesheet. I suppose that I 
> have to use the document() function to link to the XML file containing the 
> URLs, but I don't know how to do it. I've tried something like this:
> 
> This is XML file containing the URLs (link.xml):
> 
> <?xml version="1.0" encoding="utf-8" ?>
> <LINKS>
>  <L1>
>   /SomePage.aspx
>  </L1>
> </LINKS>
> 
> And this is the code from the stylesheet:
> 
> <a href="{document('link.xml')/LINKS/L1}" >
>     Some text for the anchor
> </a>
> 
> But does not work. I've tried to move the XML file in different folders to 
> make the things easy... but with no luck.

Should work. Make sure that link.xml is stored in the same directory as 
your stylesheet. Also you may want to remove whitespace before and after 
link text:

<a href="{normalize-space(document('link.xml')/LINKS/L1)}" >

Another idea - in .NET 2.0 when using XslCompiledTransform class 
document() function is disabled by default - you should get an exception 
though.

-- 
Oleg Tkachenko [XML MVP, MCAD]
http://www.XmlLab.Net | http://www.XLinq.Net | http://blog.tkachenko.com
0
some2113 (163)
4/25/2006 10:33:59 AM
Thanks for repply!
Is ther any way to reffer to the base root of a web application?
Something like the ~ character in server side.

thanks in advance



"George Bina" <george@oxygenxml.com> escribi� en el mensaje 
news:1145959377.464715.33670@i40g2000cwc.googlegroups.com...
> Hi Mario,
>
> That should work. Note that in this case link.xml in resolved relative
> to the stylesheet location. If you want it to be resolved relative to
> the XML file location then use
>
> <a href="{document('link.xml', .)/LINKS/L1}" >
>    Some text for the anchor
> </a>
>
> That is you need to pass a node set as a second argument to the
> document funtion and that nodeset system Id will be used to resolve the
> relative location specified as the first argument.
>
> Best Regards,
> George
> ---------------------------------------------------------------------
> George Cristian Bina
> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
> http://www.oxygenxml.com
> 


0
alguien (13)
4/25/2006 1:28:48 PM

Mario V�zquez wrote:


> Is ther any way to reffer to the base root of a web application?
> Something like the ~ character in server side.

You can declare a parameter e.g.
   <xsl:param name="dir" />
in your stylesheet and then pass in a value as needed before you run the 
transformation. That way you could for instance use Server.MapPath() in 
ASP to determine a file path and pass that then in to the XSLT processor.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
4/25/2006 1:50:55 PM
Reply:

Similar Artilces:

how to restore registry from the backup file
Hello everybody, I extracted the system file (registry) from the backup. I can reach the server from the rescue system loading a minimal windows. Unfortunatelly I can not start the system from the recovery disk How to restore the registry in this situation? If I try to copy it, it sayes: Cannot copy system. It is beeing used from the another programm or person. Thanks! Uwe "Uwe Conradi" <conradi@arcor.de> wrote in message news:OZtu57V4KHA.5212@TK2MSFTNGP04.phx.gbl... > Hello everybody, > I extracted the system file (registry) from the backup. >...

Create a toolbar button to automatically address an e-mail message
Hi, I have tried using MS Outlook help to create a button which automatically addresses a mail message. I cannot for the life of me succeed at this because the Help on outlook is so poor. Has anyone done this or knows how to do this?? All I am trying to do is create an "email template" that will automatically cc a colleague as they need to be cc on nearly all of my emails. So if there is an easier way to do this, that would obviously be better. Many thanks M ...

How xslt
Hi all, I have one xml doc like this <test> <orders> <order id='111' typeid='1'> <amount>300</amount> </order> <order id='112' typeid='2'> <amount>300</amount> </order> </orders> <types> <type id='1'> <name>toy</name> </type> <type id='2'> <name>food</name> </type> </types> </test> I want to use xslt to transform it into a new xml -- <test> <orders> <orde...

Open csv file in Excel XP
Hi I am opening a csv file in Excel XP and it opens the file with only one column Opening the same file in Excel Office 2000 i works up correctly It also open up the csv file correctly in Excel XP if I chose to import external data Why does not Excel XP open an comma formatted file, csv correctly Hi, What are your default delimiters set at? mine is tab, so I have to change it to comma. try double- checking this. jeff >-----Original Message----- >Hi, > >I am opening a csv file in Excel XP and it opens the file with only one column! >Opening the same file in Excel Office...

Lost my files
Hello, My laptop dropped and suddenly all my documents were gone! Trash can files are still there... Any suggestions on how to retrieve the files? Thanks! Erik Fuyu wrote: > My laptop dropped and suddenly all my documents were gone! Trash > can files are still there... > Any suggestions on how to retrieve the files? I believe you are not giving all of the story. -- Shenan Stanley MS-MVP -- How To Ask Questions The Smart Way http://www.catb.org/~esr/faqs/smart-questions.html Do a search on Google for retrieving deleted files. I'm suprised on...

Changing the dpi setting when saving a file as a jpg
does anyone know how to change the dpi setting from 150 to 300 when saving a publisher file as a jpg? In order to send your work to a printer they need at least a 300 dpi setting in order to reproduce the quality - how can I change the setting? Thanks, Lisette Hi Lisette (anonymous@discussions.microsoft.com), in the newsgroups you posted: || does anyone know how to change the dpi setting from 150 || to 300 when saving a publisher file as a jpg? In order || to send your work to a printer they need at least a 300 || dpi setting in order to reproduce the quality - how can I || change th...

OExp how to auto delete OLD files from deleted folder
Are there additional mail rules that I can load that will auto delete old deleted messages? I want to delete anything over 90 days old that is in my deleted items folder......? Thanks, Matthew ...

How do I shut off making a backup copy of a file when I save in E.
We have a shared worksheet that many people access and make changes to. Every time someone saves the file, Excel creates a backup copy of the file in the folder. How do I shut that feature off? options button on the save screen Choose File>Save As At the top right of the Save dialog box, click the Tools button Select General Options Remove the check mark from 'Always create backup' Click OK, click Save Click Yes, to replace the existing file. kboley2004 wrote: > We have a shared worksheet that many people access and make changes to. > Every time someone saves the file...

Creating array for three items
Hello all, I am reading 3 strings from a DB table. I need to apply the same process to all three strings, so I figured that I would use a for loop. To make the loop easier to handle I am going to put the three strings into an array so I can loop through each one, something like this: dim sArr() as string redim sArr(0) sArr(0) = string 1 redim preserve sArr(1) sArr(1) = string 2 redim preserve sArr(2) sArr(2) = string 3 for each sItem as string in array 'process here next That seems simple enough, except that any one of the strings might be empty. I could ...

MoveCopy, Unable to create dest.msg
Hi all, I have a user with this message "MoveCopy, Unable to create dest.msg". I have searched the newsgroup and have found others with the same problem, but no resolution. Does anyone have any ideas as to how to go about resolving this?? Thanks in advance Andy ...

Possible to include other tags in a XSLT file?
Is it possible to include addition tags in a XSLT file, that the XSLT processor will, for all practical purposes, ignore? What I'm looking to do is to include a section to contain information regarding what parameters the XSLT file is expecting. Then my program can retrieve the information from the style sheet and prompt the user for the necessary parameters. I'm envisioning the section would be something like this: <myParameters> <Param name="City" prompt="City to search for" /> <Param name="State" prompt...

cannot open pst created by outlook 2003 in Outlook xp
I've exported a mailbox to a pst file from outlook 2003. When my user tries to open this pst file from his outlook xp, he got an error saying "unable to open the file because it's created from the newer version of outlook"..... any fix? thanks calvin None. This is another example of why exporting is never the correct way to transfer Outlook data. Outlook 2003 will only export to a file format that is incompatible with all other versions. When you transfer data, create a new PST file in the correct (Outlook 97-2002) format and copy the data you want into it. -- Russ V...

How do I scale an Excel file to fit into a Word Document?
I am trying to put financials into a business plan and need to scale the cash flows etc to fit. I'd probably be minded to paste it in as a picture and then resize it whilst holding down the SHIFT key to maintain the correct proportions, else it can start to look horrible. Also saves anyone being able to get to the data from within the Word Document if that is a possible issue. -- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL 97/00/02/03 ---------------------------------------------------------------------------- It...

XSLT query
Hi I am using XSLT to transfor XML to HTML. I have an XSLT variable , $PAGELINK. I need to specify this value as an href attribute value of <a> tag. something like <a href = $PAGELINK> Click me for new page </a>. This is not working for me. $PAGELINK is treated as a text by XSLT engine. I request your help to do this. Thanks Srinivas. Cnu wrote: > I am using XSLT to transfor XML to HTML. > > I have an XSLT variable , $PAGELINK. I need to specify this value as > an href attribute value of <a> tag. > > something like <a href = $PAGELINK&g...

Access 2007 trashing Access 2003 files
Hi We run an sql server2000/access timesheet system which has been fine for years with everyone using xp and access 2003. We have one vista/access 2007 set up. Quite a few things don't work with this, however the main problem seems to be that regularly the system destroys the access front end and when you open it you get a "invalid objectid" and no further. We had access 2007 on XP for a while and it never happened with these (we rolled back to 2003 because...) wondered if there were any known issues thanks jc ...

Disable 3rd party DIC using the DYNAMICS.SET File
I'm trying to find a way to have a prompt when launching GP of wheather to load a particular 3rd party dictionary or not. I know you can manipulate the set file to have muti locations for the set of dic. Such as LOCAL and SHARED...this is by removing the workstation2 line from the DEX.INI file. But when I tried to do this and have one set of paths in the set file missing the 3rd party dictionaries.... it errors out. Any help would be Great !! You'd be better off having different dynamics.set files. When you edit the dynamics.set file, make sure you adjust three areas: 1...

XLS File
I have downloaded a excel file for a Caravan Site Fee Calculator. I have not got Microsoft Word to use it, but I can view it with the free Microsoft Excel Viewer. I have got Openoffice, which you are able to open XLS files, so I thought I could use that. When I open the file it comes up with "Error Loading Document File Read-Error This File Is Password Protested" I have not had this problem before opening xls files this way with Openoffice David, You aren't allowed to view it without the password. The password protection is doing its job. -- Earl Kiosterud ...

how to save video file
When I am at a website and I click on a video file which downloads to Windows Media player then runs, how can one then save that video file? "b11_" <b11@discussions.microsoft.com> wrote in message news:4E39ABC1-46E4-4E21-AAB3-25C48732B7A6@microsoft.com... > When I am at a website and I click on a video file which downloads to > Windows > Media player then runs, how can one then save that video file? Right click on the link that would normally open the video and then: Save Target As and save it to a location of your choice, i.e. a folder in My Documen...

Creating new class on the basis of second dialog window
Creating new class on the basis of second dialog window, which goes in only one file. One man has the second dialog window (Visual C++ 6), which takes in editbox - CString variable value. On the basis of it he creates the class CMsgDlg. As a rule, he must create in the main dialog window class member-variable m_dMsgDlg with the type CMsgDlg. Then he insert into file main_dialog_window.cpp before the line main_dialog_window.H - #include "MsgDlg.H." Then with the help of the member-variable m_dMsgDlg, from main dialog window he calls the second dialog window : if(m_dMsgDlg.DoMod...

Cannot open or import pst file
Hi, Have just had to rebuild me PC. I made sure to save and make copies of my Outlook 2002 pst files before the rebuild. I have now rebuilt and am trying to configure my Outlook 2002, only I cannot add my pst files as I get the following error message. "File access is denied. You do not have permission required to access the file". This is driving me insane, any help greatly appreciated. Cathy Exactly how are you trying to access the pst (file>open, file import, etc), and where is the pst located (hard drive, CD, Etc)? "Cathy" <ccutayar@totalise.co.uk> wr...

how do I save a column to a file (in ascii format)
I want to save a column of a spreadsheet as a file in text format. How do I do this? Thanks Copy the column. Open Notepad. Paste. Save. "joe" wrote: > I want to save a column of a spreadsheet as a file in text format. How do I > do this? > > Thanks Just noticed your ascii requirement. Looked it up and found this: "Plain text files normally use one of two types of character sets: ASCII or ANSI. DOS uses ASCII (pronounced "ask-key"). ANSI ("an-see") is the character set used by Windows. There are many variations and sub-sets but ASCII and ...

open dba files
I have Windows 2003 and Palm 1S. Trying to recover Palm archive data in .dba format. Windows won't let me cut or paste file from archive to pda. Can anyone help? Thanks. And your Word question is? "ShirleyD" <ShirleyD@discussions.microsoft.com> wrote in message news:301AF667-A258-49F3-B32C-9715B96B0DBD@microsoft.com... :I have Windows 2003 and Palm 1S. Trying to recover Palm archive data in ..dba : format. Windows won't let me cut or paste file from archive to pda. Can : anyone help? Thanks. ...

unknown lookup style
I've modified the Case form to add the "responsiblecontactid" (a predefined field), but when I attempt to add a contact to a case, I get an error: "unknown lookup style - your properties xml is probably not set properly - " Anyone resolve this yet? Jerome Hi Jerome Dont waste your time. I wasted a lot of mine. This is a "documented feature" according to Microsoft terminology. Please refer this techknowledge article for details. http://mbs.microsoft.com/techknowledge/techknowledge.asp?id=29683&target=PS Regards MBab ...

How rreliable is the CLSID method of obtaining a file location?
Folks I'm wanting to determine the version of various DAO, MSJet, ACE and ADO DLLs. One means of doing this is by using a CSIDL to get to C:\Program Files\Common Files\system\ado\msado15.dll (or close and then adding on system\ado as requiired.) Elsewhere it has been suggested that I should use the CLSID. In this case the entire key is HKEY_CLASSES_ROOT\CLSID\{00000535-0000-0010-8000-00AA006D2EA4}\InprocServer32 which I got from http://support.microsoft.com/kb/266668 Is this a relable method especially if dealing with other language OSs? Is this the best, recommended...

XL2007: File/Application Close behavior #2
So, for 25 years or whatever, if you clicked on the red "X" in the upper right corner of the window of any Microsoft application, it would close all open files and then close the application itself. And if you wanted to close just the immediate document, you clicked on the "X" at the top of the document's window, not the application's window. On my system (XP) though, XL2007 appears to behave differently. The application window "X" performs the same function as the document window "X" - it just closes the immediate document window. Is there s...