Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
i am trying, unsuccssefully , to code some xslt to outpout html,
ihave a node(publications), publication node has 3
Publication Node
pub1 offer 1
pub1 offer2
pub1 offer3
pub2 offer1
pub2 offer2
pub3 offer1
I am just doing almost the same thing. At the moment it outputs
<dl><dt>Pub 1</dt><dd>Image cropper</dd><dd>Downhill Chile Mountain Bike</dd><dt>Pub 2</dt><dd>pub 2offer 1</dd></dl>
I have done this with, translated into new schema:
<xsl:variable name="selectedNodes" select="$currentPage/Publication"/> <xsl:if test="count($selectedNodes) > 0"> <dl> <xsl:apply-templates select="$selectedNodes"> <xsl:sort select="@sortOrder" order="ascending"/> </xsl:apply-templates> </dl><!-- end #children --> </xsl:if></xsl:template><xsl:template match="Publication"> <dt><xsl:value-of select="@nodeName"/></dt> <!-- Now select the child nodes, change offer to NodeTypeAlias of child node --> <xsl:apply-templates select="./offer"> <xsl:sort select="@sortOrder" order="ascending"/> </xsl:apply-templates> </xsl:template><xsl:template match="offer"> <dd><xsl:value-of select="@nodeName"/></dd></xsl:template>
If you are not getting quite what you expect, insert <xsl:copy-of select="."/> and it will out the XML that is being processed, view in page source.
Richard
Thanks Richard,
I now have it working to a fashion, however the output is still not quite right (below)
what im trying to achieve is
imty most recent script :
<xsl:param name="currentPage"/> <xsl:template match="/"> <xsl:variable name="selectedNodes" select="$currentPage/Subscriptions"/> <xsl:if test="count($selectedNodes) > 0"> <p> <xsl:apply-templates select="$selectedNodes"> <xsl:sort select="@sortOrder" order="ascending"/> </xsl:apply-templates> </p><!-- end #children --> </xsl:if></xsl:template><xsl:template match="Subscriptions"> <xsl:variable name="ID"> <xsl:choose> <xsl:when test="position() = 1">sub-left</xsl:when> <xsl:when test="position() = 2">sub-right</xsl:when> <xsl:when test="position() = 3">sub-far-right</xsl:when> </xsl:choose> </xsl:variable> <!-- get each subscription publication options --> <div id="{$ID}" class="subs-offer-details"> <h2><xsl:value-of select="./subtitle" /> </h2> <img src="images/blank.png" width="300" height="200" /> <xsl:value-of select="./description" disable-output-escaping="yes"/> </div> <!-- Now select the child nodes, change offer to NodeTypeAlias of child node --> <xsl:apply-templates select="./SubscriptionOption"> <xsl:sort select="@sortOrder" order="ascending"/> </xsl:apply-templates> </xsl:template><xsl:template match="SubscriptionOption"> <ul> <li><xsl:value-of select="@nodeName"/>From £<xsl:value-of select="./price" /></li> </ul></xsl:template>
have tried everything i could think of...........
Grant,
I expect that the SubscriptionOptions call should be inside the DIV with class subs-offer-details, like:
<div id="{$ID}" class="subs-offer-details"> <h2><xsl:value-of select="./subtitle" /></h2> <!-- Now select the child nodes, change offer to NodeTypeAlias of child node --> <xsl:apply-templates select="./SubscriptionOption"> <xsl:sort select="@sortOrder" order="ascending"/> </xsl:apply-templates> <img src="images/blank.png" width="300" height="200" /> <xsl:value-of select="./description" disable-output-escaping="yes"/> </div>
Richard,
Thanks a million,it worked a treat
Grant
That is good to hear.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
nested xsl:for-each
i am trying, unsuccssefully , to code some xslt to outpout html,
ihave a node(publications), publication node has 3
Publication Node
pub1 offer 1
pub1 offer2
pub1 offer3
pub2 offer1
pub2 offer2
pub3 offer1
<xsl:variable name="subPubs" select="$currentPage/Publication"/>
<xsl:template match="/">
<xsl:for-each select="$subPubs"> <!-- publication options -->
<xsl:variable name="ID">
<xsl:choose>
<xsl:when test="position() = 1">sub-left</xsl:when>
<xsl:when test="position() = 2">sub-right</xsl:when>
<xsl:when test="position() = 3">sub-far-right</xsl:when>
</xsl:choose>
</xsl:variable>
<!-- get each subscription publication options -->
<div id="{$ID}" class="subs-offer-details">
<h2><xsl:value-of select="./title" />
</h2>
<img src="images/blank.png" width="300" height="200" />
<xsl:value-of select="./description" disable-output-escaping="yes"/>
</div>
<xsl:for-each select="$subPubs/offer">
<p> <xsl:value-of select="./title" /></p>
</xsl:for-each>
</xsl:for-each>
<!-- start writing XSLT -->
</xsl:template>
I am just doing almost the same thing. At the moment it outputs
I have done this with, translated into new schema:
If you are not getting quite what you expect, insert <xsl:copy-of select="."/> and it will out the XML that is being processed, view in page source.
Richard
Thanks Richard,
I now have it working to a fashion, however the output is still not quite right (below)
what im trying to achieve is
imty most recent script :
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:variable name="selectedNodes" select="$currentPage/Subscriptions"/>
<xsl:if test="count($selectedNodes) > 0">
<p>
<xsl:apply-templates select="$selectedNodes">
<xsl:sort select="@sortOrder" order="ascending"/>
</xsl:apply-templates>
</p><!-- end #children -->
</xsl:if>
</xsl:template>
<xsl:template match="Subscriptions">
<xsl:variable name="ID">
<xsl:choose>
<xsl:when test="position() = 1">sub-left</xsl:when>
<xsl:when test="position() = 2">sub-right</xsl:when>
<xsl:when test="position() = 3">sub-far-right</xsl:when>
</xsl:choose>
</xsl:variable>
<!-- get each subscription publication options -->
<div id="{$ID}" class="subs-offer-details">
<h2><xsl:value-of select="./subtitle" />
</h2>
<img src="images/blank.png" width="300" height="200" />
<xsl:value-of select="./description" disable-output-escaping="yes"/>
</div>
<!-- Now select the child nodes, change offer to NodeTypeAlias of child node -->
<xsl:apply-templates select="./SubscriptionOption">
<xsl:sort select="@sortOrder" order="ascending"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="SubscriptionOption">
<ul>
<li><xsl:value-of select="@nodeName"/>From £<xsl:value-of select="./price" /></li>
</ul>
</xsl:template>
have tried everything i could think of...........
Grant,
I expect that the SubscriptionOptions call should be inside the DIV with class subs-offer-details, like:
Richard
Richard,
Thanks a million,it worked a treat
Grant
Grant,
That is good to hear.
is working on a reply...