OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Newbie --- XSLT Transformations

[ Lists Home | Date Index | Thread Index ]

Hello,

I am new to XML and this list, so please excuse this email if i have sent it to 
the wrong list. I am attempting to teach myself xml. I have created a xml 
document, xsl stylesheet and dtd just to get my feet wet with this new 
technology. I am having a problem writing my xslt style sheet. This sytle sheet 
transforms my xml data which is just a simple news article. Contents such as

<!ELEMENT articles (article+)>
<!ELEMENT article (title, section, date, author, bi_line, img_small?, 
img_large?, text)>

I thought that would be the best way to describe the xml data that im am using. 
The problem with my stylesheet has to do with transforming img_small and 
img_large which are not required elements. Here is the data it contains

<!ELEMENT img_large (#PCDATA)>

<!ATTLIST img_large
	src CDATA "/articleImages/"
	width CDATA #REQUIRED
	height CDATA #REQUIRED
>


So what im trying to do with this element is store the location of an image for 
my article. This is to be transformed by xslt for html. So im trying to end up 
with an html <img> tag. The src attribute is the relative directory of my root 
web directory.

Everything seems to work fine when there I have a <img_large> tag in my xml 
data. But when an article doesnt have an <img_large> then my stylesheet still 
attempts to create the html <img> tag. So, is there a way i can say "If 
image_large tag exist then apply the transformation if not then dont"

Here is what i have so far for creating an img tag under my xslt stylesheet. 
This is done while looping through each article element

<img>

   <xsl:attribute name="src"><xsl:value-of select="//@src" /><xsl:value-of      
select="img_large" /></xsl:attribute>
   <xsl:attribute name="width"><xsl:value-of 
select="//@width" /></xsl:attribute>
   <xsl:attribute name="height"><xsl:value-of 
select="//@height" /></xsl:attribute>
   <xsl:attribute name="align">right</xsl:attribute>

</img>


Any help would be greatley appreciated. Again if i have posted to a non newbie 
list then please excuse this email and if you could direct me to the proper 
list that would be great.

Thanks,

    Ira
-------------------------------------------------------------
Ira M. Bargon III                                           
Online Gamming Leagues - http://www.onlinegammingleagues.com
Web Applications Developer                                  


-------------------------------------------------
eBoundHost, your web solutions partner!
http://www.eboundhost.com




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS