Dynamically assign URL hyperlinks to an image in XSLT, to be placed in InDesign CS5
I am currently using the following XSLT code to successfully/dynamically place a facebook, linkedin and twitter icon, using a conditional, if the member data in XLM shows that they have facebook (ie if the facebook element is non-empty). How开发者_如何学Go do I get the XSLT to InDesign CS5 output (not outputting to html) to automatically assign the corresponding/unique facebook URL to the image? Thanks
Here is the XSLT code (which i got to give the icon images for facebook, twitter and linked in, if there is a URL in existence):
<?xml version="1.0"?><!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY mdash "—">]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="no"/>
<xsl:template match="/">
<memberdata>
<xsl:for-each select="memberdata/memberinfo">
<xsl:sort select="SortKey"/>
<memberdata>
<xsl:if test="twitter[.!='']">
<twitter><xsl:attribute name="href">file://logos/twitter.jpg</xsl:attribute></twitter>
</xsl:if>
<xsl:if test="facebook[.!='']">
<facebook><xsl:attribute name="href">file://logos/facebook.jpg</xsl:attribute></facebook>
</xsl:if>
<xsl:if test="linkedin[.!='']">
<linkedin><xsl:attribute name="href">file://logos/linkedin.jpg</xsl:attribute></linkedin>
</xsl:if>
</memberdata>
</xsl:for-each>
</memberdata>
</xsl:template>
<xsl:template match="twitter">
</xsl:template>
<xsl:template match="facebook">
</xsl:template>
<xsl:template match="linkedin">
</xsl:template>
</xsl:stylesheet>
and the XLM:
<?xml version="1.0"?>
<memberdata xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
<memberinfo>
<email>email1@abc.com</email>
<facebook>http://www.URL1a.com</facebook>
<linkedin>http://www.URL1b.com</linkedin>
<vimeo>http://www.URL1c.com</vimeo>
</memberinfo>
<memberinfo>
<email>email2@abc.com</email>
<facebook>http://www.URL2a.com</facebook>
<linkedin>http://www.URL2b.com</linkedin>
<vimeo>http://www.URL2c.com</vimeo>
</memberinfo>
</memberdata>
You don't need to if
for your elements - this will handle the template for you:
<xsl:template match="twitter[.!='']">
<twitter>
<xsl:attribute name="href">file://logos/twitter.jpg</xsl:attribute>
</twitter>
</xsl:template>
<xsl:template match="facebook[.!='']">
<facebook>
<xsl:attribute name="href">file://logos/facebook.jpg</xsl:attribute>
</facebook>
</xsl:template>
<xsl:template match="linkedin[.!='']">
<linkedin>
<xsl:attribute name="href">file://logos/linkedin.jpg</xsl:attribute>
</linkedin>
</xsl:template>
Maybe you can add the desired output for your sample xml ... it's not clear what should happen with <email />
elements for example.
精彩评论