473,782 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSLT problem. Can I please have a little help here to create a hyperlink.

I want to write a xslt template to create a xhtml 1.0 (transitional)
file which will be sent in as email.

Here is a typical xml data file:

<BatchEmail>
<Domain>www.myD omain.com</Domain>
<Destination>
<Salutation>H i Mark</Salutation>
<UniqueID>412 0</UniqueID>
<Folder>Lite</Folder>
</Destination>
<Reports>
<Report ID="3434">
<Headline>'Trif fids' Are Invading!</Headline>
<Preface>Gian t mobile plant-like creatures have descending on
Cheltenham and are attacking all animals in sight. Scientists have
named these mysterious creatures 'Triffids'.</Preface>
</Report>
<Report ID="3435">
<Headline>Marti an Ambassador Causes Diplomatic Incident</Headline>
<Preface>The Martian ambassador has caused a diplomatic incident
after it accidently eat the Big Apple. On immediately regurgitating New
York City the Ambassador was heard to mutter 'didn't taste anything
like an apple'</Preface>
</Report>
</Reports>
</BatchEmail>
This is what I need the xlst to create from that:

<p>Hi Mark,</p>
<h4>'Triffids ' Are Invading!</h4>
<p>Giant mobile plant-like creatures have descending on Cheltenham and
are attacking all animals in sight. Scientists have named these
mysterious creatures 'Triffids'.</p>
<p>Read the full report here:<br /><a target="_blank"
href="http://www.myDomain.co m/Lite/ViewReport.aspx ?ReportID=3434" >http:/
/www.myDomain.co m/Lite/ViewReport.aspx ?ReportID=3434</a></p>
<h4>Martian Ambassador Causes Diplomatic Incident</h4>
<p>The Martian ambassador has caused a diplomatic incident after it
accidently eat the Big Apple. On immediately regurgitating New York
City the Ambassador was heard to mutter 'didn't taste anything like an
apple'</p>
<p>Read the full report here:<br /><a target="_blank"
href="http://www.myDomain.co m/Lite/ViewReport.aspx ?ReportID=3435" >http:/
/www.myDomain.co m/Lite/ViewReport.aspx ?ReportID=3435</a></p>
When the xml file has a Folder value of Full (in place of Lite). I'd
like a slightly different xhtml (i.e. with an extra line):

<p>Hi Mark,</p>
<h4>'Triffids ' Are Invading!</h4>
<p>Giant mobile plant-like creatures have descending on Cheltenham and
are attacking all animals in sight. Scientists have named these
mysterious creatures 'Triffids'.</p>
<p>Read the full report here:<br /><a target="_blank"
href="http://www.myDomain.co m/Full/ViewReport.aspx ?ReportID=3434" >http:/
/www.myDomain.co m/Full/ViewReport.aspx ?ReportID=3434</a></p>
<h4>Martian Ambassador Causes Diplomatic Incident</h4>
<p>The Martian ambassador has caused a diplomatic incident after it
accidently eat the Big Apple. On immediately regurgitating New York
City the Ambassador was heard to mutter 'didn't taste anything like an
apple'</p>
<p>Read the full report here:<br /><a target="_blank"
href="http://www.myDomain.co m/Full/ViewReport.aspx ?ReportID=3435" >http:/
/www.myDomain.co m/Full/ViewReport.aspx ?ReportID=3435</a></p>
<p>You can do a full search of our database at the search page: <a
target="_blank"
href="http://www.myDomain.co m/Search/Search.aspx">http://www.myDomain.co
m/Search/Search.aspx</a></p>
I'm having some trouble creating the the url in the hyperlink. For
instance my editor shows it as so (in the .net 2.0 framework, Browser
object windown):

http://{$domain}/{$folder}/ViewReport.aspx ?ReportID=1001

Navigating from there takes me to this page:

http://%7B$domain%7D/{$folder}/ViewReport.aspx ?ReportID=1001

That comes from the following xslt:

<a target="_blank" ><xsl:attribu te
name="href">htt p://{$domain}/{$folder}/ViewReport.aspx ?ReportID=<xsl: val
ue-of select="@ID"/></xsl:attribute>
<span
class="link2">h ttp://{$domain}/{$folder}/ViewReport.aspx ?ReportID=<xsl: v
alue-of select="@ID"/></span>

That xslt snippet above is itself inside a loop. So the relevant part
is:

<xsl:variable name="domain" select="BatchEm ail/Domain"/>
<xsl:variable name="folder" select="BatchEm ail/Destination/Folder"/>
<xsl:for-each select="BatchEm ail/Reports/Report">

blah blah ...

<a target="_blank" ><xsl:attribu te
name="href">htt p://{$domain}/{$folder}/ViewReport.aspx ?ReportID=<xsl: val
ue-of select="@ID"/></xsl:attribute>
<span
class="link2">h ttp://{$domain}/{$folder}/ViewReport.aspx ?ReportID=<xsl: v
alue-of select="@ID"/></span>

blah blah blah ...
<xsl:if test="$folder = 'Full'">
blah blah blah blah ...
</xsl:if>

blah blah blah blah blah ...

</xsl:for-each>
[the 1001 there is OK, it's just a place holder for the actual value
from the xml. The editor doesn't know anthing about an actual data file
at this stage as email posting is not yet running (as I haven't even
saved my xslt template yet.)

I having tested this program yet as I need to enter the relevant 'Lite'
users in the database, make sure the web service is propertly running
etc. and I'm not confident with that url above.
Dec 21 '07 #1
4 2758

Uzytkownik "mark4asp" <ma******@gmail .comnapisal w wiadomosci
news:01******** **************@ news.astraweb.c om...
>I want to write a xslt template to create a xhtml 1.0 (transitional) file
which will be sent in as email.

<a target="_blank" ><xsl:attribu te
name="href">htt p://{$domain}/{$folder}/ViewReport.aspx ?ReportID=<xsl: val
ue-of select="@ID"/></xsl:attribute>
<span
class="link2">h ttp://{$domain}/{$folder}/ViewReport.aspx ?ReportID=<xsl: v
alue-of select="@ID"/></span>
should be like that:
<a target="_blank" ><xsl:attribu te
name="href">htt p://<xsl:value-of select="$domain "/>/<xsl:value-of
select="$folder "/>/ViewReport.aspx ?ReportID=<xsl: val
ue-of select="@ID"/></xsl:attribute>
<span
class="link2">h ttp://<xsl:value-of select="$domain "/>//<xsl:value-of
select="$folder "/>//ViewReport.aspx ?ReportID=<xsl: v
alue-of select="@ID"/></span>

--
td
XMLguru.net
Dec 21 '07 #2
TOUDIdel wrote:
>
Uzytkownik "mark4asp" <ma******@gmail .comnapisal w wiadomosci
news:01******** **************@ news.astraweb.c om...
I want to write a xslt template to create a xhtml 1.0
(transitional) file which will be sent in as email.


<a target="_blank" ><xsl:attribu te
name="href">htt p://{$domain}/{$folder}/ViewReport.aspx ?ReportID=<xsl: v
al ue-of select="@ID"/></xsl:attribute>
<span
class="link2">h ttp://{$domain}/{$folder}/ViewReport.aspx ?ReportID=<xsl
:v alue-of select="@ID"/></span>
should be like that:
<a target="_blank" ><xsl:attribu te
name="href">htt p://<xsl:value-of select="$domain "/>/<xsl:value-of
select="$folder "/>/ViewReport.aspx ?ReportID=<xsl: val ue-of
select="@ID"/></xsl:attribute<s pan
class="link2">h ttp://<xsl:value-of select="$domain "/>//<xsl:value-of
select="$folder "/>//ViewReport.aspx ?ReportID=<xsl: v alue-of
select="@ID"/></span>
So if I reduce it to the simplest form, is this it:

<a target="_blank" class="link2">< xsl:attribute
name="href">htt p://<xsl:value-of select="$domain "/>/<xsl:value-of
select="$folder "/>/ViewReport.aspx ?ReportID=<xsl: value-of
select="@ID"/></xsl:attribute>
http://<xsl:value-of select="$domain "/>/<xsl:value-of
select="$folder "/>/ViewReport.aspx ?ReportID=<xsl: value-of select="@ID"/>
</a>

I notice you have two / where I only have one (in the display part of
the hyperlink). Is your's a typo or is my hyperlink above wrong?
Dec 21 '07 #3
>
I'm having some trouble creating the the url in the hyperlink. For
instance my editor shows it as so (in the .net 2.0 framework, Browser
object windown):
<a target="_blank" ><xsl:attribu te
name="href">htt p://{$domain}/{$folder}/ViewReport.aspx ?ReportID=<xsl: val
ue-of select="@ID"/></xsl:attribute>

{} braces are just character data when used in element content. You have
to use xsl:value-of in that context (as you did for @ID)
so
<a target="_blank" ><xsl:attribu te
name="href">htt p://<xsl:value-of select="$domain "/>/<xsl:value-of
select="$folder "/>/ViewReport.aspx ?ReportID=<xsl: value-of
select="@ID"/></xsl:attribute>

or more simply use attribute value templates:

<t target="_blank"
href="http://{$domain}/{$folder}/ViewReport.aspx ?ReportID={@ID} ">

David

--
http://dpcarlisle.blogspot.com
Dec 21 '07 #4

Użytkownik "mark4asp" <ma******@gmail .comnapisał w wiadomo¶ci
news:00******** **************@ news.astraweb.c om...
I notice you have two / where I only have one (in the display part of
the hyperlink). Is your's a typo or is my hyperlink above wrong?
what's the problem? there are many equivalent solutions
--
td
Dec 23 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8690
by: Victor | last post by:
Hi, this might sound silly but I cannot figure out how to incorporate some XML of employees into some XML of a company to give new XML containing them all. For example, this is the company now <COMPANY> <EMPLOYEE currentEmployee="true"> <NAME>Victor</NAME>
1
15093
by: Matt | last post by:
For example, how to represent hyperlink in XSL? I want to add hyperlink in XSL. i.e. I need to generate <A HREF="http://mypage.html">home page</A> in HTML. I tried the following approaches but still not work, it don't display anything Approach #1: direct link, not work A) double quote, <A HREF="<xsl:value-of select="/bio/homepage" />">home page</A> OR B) single quote, <A HREF='<xsl:value-of select="/bio/homepage" />'>home page</A>
2
1390
by: Flyzone | last post by:
Hi all, i have a little problem.... in the XML i have a tag named "title", where there is the text that i want to use for the title of the card name in the resul WML. The problem is that i cant write <card id="guest" title="<xsl:apply-templates select="//title"/>"> cause the tag will be bad-formed. How can i solve this? Thanks in advance,
5
1466
by: dennis | last post by:
Hi, First of all, hi to you all. I'm working on a Delphi project wich is becoming near it's deadline. I have a very simple XSLT question wich i hope one of you folks can help me with? The problem is i need to transform a xml file from this: <root>
2
5287
by: chris | last post by:
Hi there, I create an XML file from a dataset like this: System.IO.StreamWriter xmlSW = new System.IO.StreamWriter(FILENAME); dsUserData1.WriteXml(xmlSW, XmlWriteMode.WriteSchema); xmlSW.Close(); Which gives me this XML file: <NewDataSet>
7
2869
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID parameter to the XSLT stylesheet XsltArgumentList xsltArgList = new XsltArgumentList(); xsltArgList.AddParam("pmID", "", pmID); xmlItems.TransformArgumentList = xsltArgList;
2
1434
by: Stephen | last post by:
I have a little predicamnet. I have two xml controls on my page. Both are menus for my site. The first (Category) needs to set the data source of the other xml control. To do this I created an xslt file that generates the value of each item in the first xml file as hyperlink. Easy enough. Next I needed the hyperlink to execute C# code in order to load the second xml control with the appropriate xml file. I placed a hidden button on...
6
2657
by: Pete Verdon | last post by:
Summary: Can I do an XSLT transform, in the client, of a tree of nodes taken from the displayed page DOM in IE? This works in Firefox. Hi, I'm just starting the process of rewriting part of a "database frontend" type of intranet application. The existing table-display code consists of a mountain of very clever but extremely brittle spaghetti-javascript, which I'm planning to replace with XSLT transformations. At present I'm still...
2
4052
by: Craig | last post by:
Hello there, I'm trying to generate a hyperlink (href) using XSLT to generate a web page that displays a table with selected information. At the moment everything is working except for the hyperlink which I can't seem to get my head around. I have the XSLT code listed below so if anyone can let me know what the problem is with my script I would be greatly appreciated. Here is the code: <?xml version="1.0"?>
0
9479
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10311
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9942
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7492
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3639
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.