Hello,
I haven't made a XSL in quite sometime so i am very rusty. Basicly i want the XSL to display a defined image if one is not present in the XML.
here is my current XSL and XML will be below that, hope you can help. - <?xml version='1.0' encoding='utf-8' ?>
-
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-
<xsl:output method="html" encoding="ISO-8859-1" omit-xml-declaration="yes"/>
-
-
<xsl:param name="pagename">default.asp?pagename=media&content=getcontent</xsl:param>
-
<xsl:param name="lang">en</xsl:param>
-
<xsl:param name="type">print</xsl:param>
-
<xsl:param name="vol">200304</xsl:param>
-
<xsl:param name="cat">2</xsl:param>
-
<xsl:param name="articleid">12345</xsl:param>
-
<xsl:param name="mode">preview</xsl:param>
-
<xsl:param name="target">email</xsl:param>
-
-
<xsl:variable name="strBaseURL"><xsl:value-of select="concat('type=',$type,'&lang=',$lang,'&vol=',$vol,'&cat=',$cat,'&articleid=',$articleid)"></xsl:value-of></xsl:variable>
-
-
<xsl:variable name="default" select="document('../xml/default.xml')/main/site[@language=$lang]"/>
-
-
<xsl:variable name="website_IP"><xsl:value-of select="$default/website_IP"/></xsl:variable>
-
-
<xsl:variable name="twidth">
-
<xsl:choose>
-
<xsl:when test="$target='web'"><xsl:text>100%</xsl:text></xsl:when>
-
<xsl:otherwise><xsl:text>750</xsl:text></xsl:otherwise>
-
</xsl:choose>
-
</xsl:variable>
-
-
<xsl:variable name="image_dir">
-
<xsl:choose>
-
<xsl:when test="$target='web'"><xsl:value-of select="$default/web_article_images_url"/></xsl:when>
-
<xsl:when test="$target='email' or $target='index'"><xsl:value-of select="$website_IP"/><xsl:value-of
-
-
select="$default/web_article_images_url"/></xsl:when>
-
<xsl:when test="$target='cd'"><xsl:value-of select="$default/cd_article_images_url"/></xsl:when>
-
</xsl:choose>
-
</xsl:variable>
-
-
-
-
<xsl:variable name="viewpagename"><xsl:text>default.asp?pagename=media&content=getcontent</xsl:text></xsl:variable>
-
<xsl:variable name="downloadpagename"><xsl:text>default.asp?pagename=media&content=getcontent</xsl:text></xsl:variable>
-
-
<xsl:template match="vol_issue">
-
<xsl:variable name="view_text">
-
<xsl:choose>
-
<xsl:when test="type = 'print' or type = 'web'">
-
<xsl:choose>
-
<xsl:when test="language='en'">View this article</xsl:when>
-
<xsl:otherwise>Visualiser cet article</xsl:otherwise>
-
</xsl:choose>
-
</xsl:when>
-
<xsl:when test="type = 'digital'">
-
<xsl:choose>
-
<xsl:when test="language='en'">Watch this video</xsl:when>
-
<xsl:otherwise>Regarder ce vidéo</xsl:otherwise>
-
</xsl:choose>
-
</xsl:when>
-
<xsl:when test="type = 'pr'">
-
<xsl:choose>
-
<xsl:when test="language='en'">View this release</xsl:when>
-
<xsl:otherwise>Visualiser ce communiqué</xsl:otherwise>
-
</xsl:choose>
-
</xsl:when>
-
<xsl:otherwise>
-
<xsl:choose>
-
<xsl:when test="language='en'">View this script</xsl:when>
-
<xsl:otherwise>Visualiser ce script</xsl:otherwise>
-
</xsl:choose>
-
</xsl:otherwise>
-
</xsl:choose>
-
</xsl:variable>
-
-
<xsl:variable name="email_text">
-
<xsl:choose>
-
<xsl:when test="type ='print' or type='web'">
-
<xsl:choose>
-
<xsl:when test="language='en'">E-mail me this article</xsl:when>
-
<xsl:otherwise>Veuillez me transmettre cet article par courriel</xsl:otherwise>
-
</xsl:choose>
-
</xsl:when>
-
<xsl:when test="type ='pr'">
-
<xsl:choose>
-
<xsl:when test="language='en'">E-mail me this release</xsl:when>
-
<xsl:otherwise>Envoyer ce communiqué par courriel</xsl:otherwise>
-
</xsl:choose>
-
</xsl:when>
-
<xsl:when test="type ='digital'">
-
</xsl:when>
-
<xsl:otherwise>
-
<xsl:choose>
-
<xsl:when test="language='en'">E-mail me this script</xsl:when>
-
<xsl:otherwise>Veuillez me transmettre ce script par courriel</xsl:otherwise>
-
</xsl:choose>
-
</xsl:otherwise>
-
</xsl:choose>
-
</xsl:variable>
-
<xsl:variable name="cat_description" select="document('../articles/categories.xml')/main/category[@category_id = $cat]/description"/>
-
<div class="m-bcategory"><h1><xsl:value-of select="$cat_description"/></h1></div>
-
<xsl:for-each select="category[@category_id = $cat]/article">
-
<xsl:variable name="article" select="document(concat('../articles/', @article_id, '.xml'))"/>
-
<div class="m-blurbwrapper">
-
<div class="m-bheadline"><a class="m-bheadline"
-
-
href="{$viewpagename}&type={../../type}&lang={../../language}&vol={../../@vol_issue_id}&cat={../@category_id}&articleID={@article_id}&mode=view&id={$article/article/video/file/file_name}"><xsl:value-of select="$article/article/headline"/></a></div>
-
-
-
<div style="float:left;"><img src="{$image_dir}{$article/article/images/image/source}" border="0" width="70" height="50"/>
-
</div>
-
-
-
<div class="m-awordcount"><xsl:value-of select="$article/article/body_text/wordcount"/></div>
-
-
<div class="m-bblurb"><xsl:value-of select="$article/article/blurb"/></div>
-
-
-
<div class="m-blink">
-
<a class="m-blink"
-
-
href="{$viewpagename}&type={../../type}&lang={../../language}&vol={../../@vol_issue_id}&cat={../@category_id}&articleID={@article_id}&mode=view&id={$article/article/video/file/file_name}">
-
<xsl:value-of select="$view_text"/>
-
</a>
-
<xsl:if test="../../type='print' or ../../type='web' or ../../type='pr' or ../../type='digital'">
-
***<a class="m-blink"
-
-
href="{$downloadpagename}&type={../../type}&lang={../../language}&vol={../../@vol_issue_id}&cat={../@category_id}&articleID={@article_id}&mode=email">
-
<xsl:value-of select="$email_text"/>
-
</a>
-
</xsl:if>
-
</div>
-
</div>
-
</xsl:for-each>
-
</xsl:template>
-
</xsl:stylesheet>
XML - <?xml version="1.0" encoding="UTF-8"?>
-
<!DOCTYPE article SYSTEM "article.dtd" [
-
]>
-
<article>
-
<headline>display this works</headline>
-
<subheadline></subheadline>
-
<blurb>display this works</blurb>
-
<byline></byline>
-
<copyright></copyright>
-
<body_text></body_text>
-
<images>
-
<image>
-
<source>someimage.jpg</source>
-
<res_type>low</res_type>
-
</image>
-
<image>
-
<source>someimage.jpg</source>
-
<res_type>hi</res_type>
-
</image>
-
</images>
-
<audio>
-
<file>
-
<file_name></file_name>
-
<file_type></file_type>
-
</file>
-
</audio>
-
<video></video>
-
</article>
6 2210
Where you have:
<img src="{$image_dir}{$article/article/images/image/source}" />
replace with something like:
<img border="0" width="70" height="50">
<xsl:attribute name="src">
<xsl:value-of select="$image_dir"/>
<xsl:value-of select="$article/article/images/image/source"/>
<xsl:if test="not($article/article/images/image/source)">defaultimage.jpg</xsl:if>
</xsl:attribute>
</img>
Well i tried your solution, and i just get the same efftect.
If the image is in the XML it displays the image but if no image in the XML
I just get an image cell (i am starting to hate that red x)
The above assumes that you have the defined image in defaultimage.jpg
Perhaps your defined image is named differently?
It also assumed your defined image was in the same image directory.
The above assumes that you have the defined image in defaultimage.jpg
Perhaps your defined image is named differently?
It also assumed your defined image was in the same image directory.
- <div style="float:left;">
-
<img border="0" width="70" height="50">
-
<xsl:attribute name="src">
-
<xsl:value-of select="$image_dir"/>
-
<xsl:value-of select="$article/article/images/image/source"/>
-
<xsl:if test="not($article/article/images/image/source)">noimage.jpg</xsl:if>
-
</xsl:attribute>
-
</img>
-
</div>
yes the image is in the dir, though it still does not display.
ah, do you have an empty existing source node?
Instead change the if test to:
<xsl:if test="$article/article/images/image/source = ''">noimage.jpg</xsl:if>
which instead tests if the the string is empty as opposed to the node not being there.
ah, do you have an empty existing source node?
Instead change the if test to:
<xsl:if test="$article/article/images/image/source = ''">noimage.jpg</xsl:if>
which instead tests if the the string is empty as opposed to the node not being there.
Ah i knew it was something small that i was over looking, thank you for your input and help, that works perfectly.
Thank you again.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: jbrewer |
last post by:
I'm trying to read in a FITs image file for my research, and I decided
that writing a file decoder for the Python imaging library would be the
easiest way to accomplish this for my needs. FITs is...
|
by: Charlie King |
last post by:
As I understand it, the use of FIR* to replace heading tags with
images in visually enabled CSS browsers is now frowned upon on the
basis that some screen readers will *nor* read back text that is...
|
by: Manuel |
last post by:
Is it possible to embed an image, like a company logo in a CDOSYS generated
message?
If yes, I´ll apreciate some code sample. I´ve been able to format messages
in html the way I like, but I...
|
by: CDMAPoster |
last post by:
In:
http://groups.google.com/group/comp.databases.ms-access/msg/9c3dcf952fc3e3d3
I said:
'-----
In:
http://groups.google.com/group/comp.databases.ms-access/msg/c368352c1...
|
by: Ricardo Furtado |
last post by:
I'm trying, for a week or two, to create a procedure in order to rotate the
image in any picturebox control in a cephalometry software. I've found a web
site that shows how that can be done:...
|
by: Peter |
last post by:
I have a problem with a page show_image.asp that returns a jpg image under
Windows XP Pro SP2. The page sets content type as:
Response.ContentType = "image/jpg"
While this works perfectly fine...
|
by: Ari Krupnik |
last post by:
Image.width returns the width of an image as it is displayed on a
browser page, which may be different from the image's intrinsic size
if the 'img' element had a 'width' attribute specified. Is...
|
by: Jon Slaughter |
last post by:
can one "stream" image data to a browser?
I created an image using gd and when I do imagepng I just get the binary
data for the image written as text instead of the image itself. Now I'm...
|
by: =?Utf-8?B?S2VuTg==?= |
last post by:
We're using a System.Windows.Forms.ImageList to store a bunch of Images that
I've loaded, and rendering each image in the ImageList during a draw loop.
The process was running unusually slow and...
|
by: Roderik |
last post by:
Hi,
I guess I am missing something. I tried to put a caption on my photo (on
the bottom) but the caption appears to be a bit higher and overshooting
the area of the image with a few pix.
You...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |