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.