[xsl] replacing images with alt tags

Subject: [xsl] replacing images with alt tags
From: "Jacob P. Glenn" <jpglenn2@xxxxxxxxxxx>
Date: Thu, 18 Apr 2002 02:22:23 -0400
I am trying to remove images when converting from xhtml to wml.  I want
to replace them with their alt tags.  Below is my xslt.  I want to
handle different cases such that if the image is the link for an anchor
tag it is replaced with the alt text, if it is within a <p> tag then it
places the alt tag in its place, and last if it is not within either of
the above then it places the alt tag within its own <p> tags.  What I
have below is not working.  The only part that works is the otherwise
part.  Is there something wrong with my choose?  How can I do this
better?  And how can I get the alt text to replace the ||image skipped||
that I currently have?  And better yet is their a good way to do away
with this and convert images?  That's probably wishful thinking :)

<xsl:template match="img">	
	<xsl:choose>
	<xsl:when test="parent::a">	<!--img presents the src for an
image if the image is a link ie. has parent::a-->
		 <xsl:copy-of select="@alt"/>
 	</xsl:when>
	<xsl:when test="parent::p">
	   	  (image - <xsl:copy-of select="@alt"/>)
    	</xsl:when>
	<xsl:otherwise>
	    	<p>
	    	||image skipped||
	   	</p>
	</xsl:otherwise>
	</xsl:choose>
</xsl:template>

Jacob

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread