Jump to content

DVezina

Members
  • Posts

    17
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Orlando Florida

DVezina's Achievements

Newbie

Newbie (1/7)

1

Reputation

  1. OK one more try ...DITA eh?All the element ids are stored in a key called "key_anchor". This is defined in links.xsl.Make sure your step actually has an id attribute in the MERGED XML. This sounds silly but if this is running through the DITA toolkit, strange things can happen.You want to put the <fo:inline> in your step template. task-elements.xsl<xsl:template match="*[contains(@class, ' task/steps ')]/*[contains(@class, ' task/step ')]"><fo:inline id="{@id}"/>Then in your xref template, you should find the matching id in the key_anchor.Now you are truly pointing at the step and you get the page number or get it's count from the element "steps".Something like this:<fo:inline color="blue"><xsl:for-each select="key('key_anchor',@href)"><!-- Found the step with the matching id --><fo:basic-link internal-destination="{@id}"><!-- Or count step from steps --><xsl:text>See page </xsl:text><fo:page-number-citation ref-id="{$destination}"/></fo:basic-link></xsl:for-each></fo:inline>Hope this helps!
  2. Well that posted incorrectly.Here it is again. --DITA eh? All the element ids are stored in a key called "key_anchor". This is defined in links.xsl. Make sure your step actually has an id attribute in the MERGED XML. This sounds silly but if this is running through the DITA toolkit, strange things can happen.You want to put the <fo:inline> in your step template. task-elements.xsl<xsl:template match="*[contains(@class, ' task/steps ')]/*[contains(@class, ' task/step ')]"><fo:inline id="{@id}"/>Then in your xref template, you should find the matching id in the key_anchor. Now you are truly pointing at the step and you get the page number or get it's count from the element "steps". Something like this:<fo:inline color="blue"><xsl:for-each select="key('key_anchor',@href)"><!-- Found the step with the matching id --><fo:basic-link internal-destination="{@id}"><!-- Or count step from steps --><xsl:text>See page </xsl:text><fo:page-number-citation ref-id="{$destination}"/></fo:basic-link></xsl:for-each></fo:inline>Hope this helps!
  3. DITA eh? All the element ids are stored in a key called "key_anchor". This is defined in links.xsl. Make sure your step actually has an id attribute in the MERGED XML. This sounds silly but if this is running through the DITA toolkit, strange things can happen.You want to put the <fo:inline> in your step template. task-elements.xsl [size="1"]<xsl:template match="*[contains(@class, ' task/steps ')]/*[contains(@class, ' task/step ')]">[/size][size="1"]<fo:inline id="{@id}"/>[/size] Then in your xref template, you should find the matching id in the key_anchor. Now you are truly pointing at the step and you get the page number or get it's count from the element "steps". Something like this: [size="1"]<fo:inline color="blue">[/size][size="1"]<xsl:for-each select="key('key_anchor',@href)">[/size][size="1"]<!-- Found the step with the matching id -->[/size][size="1"]<fo:basic-link internal-destination="{@id}">[/size][size="1"]<!-- Or count step from steps -->[/size][size="1"]<xsl:text>See page </xsl:text><fo:page-number-citation ref-id="{$destination}"/>[/size][size="1"]</fo:basic-link>[/size][size="1"]</xsl:for-each>[/size][size="1"]</fo:inline>[/size] Hope this helps!
  4. I'm posting this for zoomer003. "<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ><xsl:param name="ResultsBy" /><xsl:param name="ViewByUrl" /><xsl:param name="ViewByValue" /><xsl:param name="IsNoKeyword" /><xsl:param name="IsFixedQuery" /><xsl:param name="ShowActionLinks" /><xsl:param name="MoreResultsText" /><xsl:param name="MoreResultsLink" /><xsl:param name="CollapsingStatusLink" /><xsl:param name="CollapseDuplicatesText" /><xsl:param name="AlertMeLink" /><xsl:param name="AlertMeText" /><xsl:param name="SrchRSSText" /><xsl:param name="SrchRSSLink" /><xsl:param name="ShowMessage" /><xsl:param name="IsThisListScope" /><xsl:param name="DisplayDiscoveredDefinition" select="True" /><xsl:param name="NoFixedQuery" /><xsl:param name="NoKeyword" /><xsl:param name="NoResults" /><xsl:param name="NoResults1" /><xsl:param name="NoResults2" /><xsl:param name="NoResults3" /><xsl:param name="NoResults4" /><xsl:param name="DefinitionIntro" /><!-- When there is keywory to issue the search --><xsl:template name="dvt_1.noKeyword"><span class="srch-description"><xsl:choose><xsl:when test="$IsFixedQuery"><xsl:value-of select="$NoFixedQuery" /></xsl:when><xsl:otherwise><xsl:value-of select="$NoKeyword" /></xsl:otherwise></xsl:choose></span></xsl:template><!-- When empty result set is returned from search --><xsl:template name="dvt_1.empty"><div class="srch-sort"><xsl:if test="$AlertMeLink and $ShowActionLinks"><span class="srch-alertme" > <a href ="{$AlertMeLink}" id="CSR_AM1" title="{$AlertMeText}"><img style="vertical-align: middle;" src="/_layouts/images/bell.gif" alt="" border="0"/><xsl:text disable-output-escaping="yes">&nbsp;</xsl:text><xsl:value-of select="$AlertMeText" /></a></span></xsl:if><xsl:if test="string-length($SrchRSSLink) > 0 and $ShowActionLinks"><xsl:if test="$AlertMeLink">|</xsl:if><a type="application/rss+xml" href ="{$SrchRSSLink}" title="{$SrchRSSText}" id="SRCHRSSL"><img style="vertical-align: middle;" border="0" src="/_layouts/images/rss.gif" alt=""/><xsl:text disable-output-escaping="yes">&nbsp;</xsl:text><xsl:value-of select="$SrchRSSText"/></a></xsl:if></div><br/> <br/><span class="srch-description" id="CSR_NO_RESULTS"><xsl:value-of select="$NoResults" /><ol><li><xsl:value-of select="$NoResults1" /></li><li><xsl:value-of select="$NoResults2" /></li><li><xsl:value-of select="$NoResults3" /></li><li><xsl:value-of select="$NoResults4" /></li></ol></span></xsl:template><!-- Main body template. Sets the Results view (Relevance or date) options --><xsl:template name="dvt_1.body"><div class="srch-results"><xsl:if test="$ShowActionLinks"><div class="srch-sort"> <xsl:value-of select="$ResultsBy" /><xsl:if test="$ViewByUrl">|<a href ="{$ViewByUrl}" id="CSR_RV" title="{$ViewByValue}"><xsl:value-of select="$ViewByValue" /></a></xsl:if><xsl:if test="$AlertMeLink">|<span class="srch-alertme" > <a href ="{$AlertMeLink}" id="CSR_AM2" title="{$AlertMeText}"><img style="vertical-align: middle;" src="/_layouts/images/bell.gif" alt="" border="0"/><xsl:text disable-output-escaping="yes">&nbsp;</xsl:text><xsl:value-of select="$AlertMeText" /></a></span></xsl:if><xsl:if test="string-length($SrchRSSLink) > 0">|<a type="application/rss+xml" href ="{$SrchRSSLink}" title="{$SrchRSSText}" id="SRCHRSSL"><img style="vertical-align: middle;" border="0" src="/_layouts/images/rss.gif" alt=""/><xsl:text disable-output-escaping="yes">&nbsp;</xsl:text><xsl:value-of select="$SrchRSSText"/></a></xsl:if></div><br /><br /></xsl:if><xsl:apply-templates /></div><xsl:call-template name="DisplayMoreResultsAnchor" /></xsl:template><!-- This template is called for each result --><xsl:template match="Result"><xsl:variable name="id" select="id"/><xsl:variable name="url" select="url"/><span class="srch-Icon"><a href="{$url}" id="{concat('CSR_IMG_',$id)}" title="{$url}"><img align="absmiddle" src="{imageurl}" border="0" alt="{imageurl/@imageurldescription}" /></a></span><span class="srch-Title"><a href="{$url}" id="{concat('CSR_',$id)}" title="{$url}"><xsl:choose><xsl:when test="hithighlightedproperties/HHTitle[. != '']"><xsl:call-template name="HitHighlighting"><xsl:with-param name="hh" select="hithighlightedproperties/HHTitle" /></xsl:call-template></xsl:when><xsl:otherwise><xsl:value-of select="title"/></xsl:otherwise></xsl:choose></a><br/></span><xsl:choose><xsl:when test="$IsThisListScope = 'True' and contentclass[. = 'STS_ListItem_PictureLibrary'] and picturethumbnailurl[. != '']"><div style="padding-top: 2px; padding-bottom: 2px;"><a href="{$url}" id="{concat('CSR_P',$id)}" title="{title}"><img src="{picturethumbnailurl}" alt="" /></a></div></xsl:when></xsl:choose><div class="srch-Description"><xsl:choose><xsl:when test="hithighlightedsummary[. != '']"><xsl:call-template name="HitHighlighting"><xsl:with-param name="hh" select="hithighlightedsummary" /></xsl:call-template></xsl:when><xsl:when test="description[. != '']"><xsl:value-of select="description"/></xsl:when></xsl:choose></div ><p class="srch-Metadata"><span class="srch-URL"><a href="{$url}" id="{concat('CSR_U_',$id)}" title="{$url}" dir="ltr"><xsl:choose><xsl:when test="hithighlightedproperties/HHUrl[. != '']"><xsl:call-template name="HitHighlighting"><xsl:with-param name="hh" select="hithighlightedproperties/HHUrl" /></xsl:call-template></xsl:when><xsl:otherwise><xsl:value-of select="url"/></xsl:otherwise></xsl:choose></a></span><xsl:call-template name="DisplayCollapsingStatusLink"><xsl:with-param name="status" select="collapsingstatus"/><xsl:with-param name="urlEncoded" select="urlEncoded"/><xsl:with-param name="id" select="concat('CSR_CS_',$id)"/></xsl:call-template></p></xsl:template><xsl:template name="HitHighlighting"><xsl:param name="hh" /><xsl:apply-templates select="$hh"/></xsl:template><xsl:template match="ddd">…</xsl:template><xsl:template match="c0"><b><xsl:value-of select="."/></b></xsl:template><xsl:template match="c1"><b><xsl:value-of select="."/></b></xsl:template><xsl:template match="c2"><b><xsl:value-of select="."/></b></xsl:template><xsl:template match="c3"><b><xsl:value-of select="."/></b></xsl:template><xsl:template match="c4"><b><xsl:value-of select="."/></b></xsl:template><xsl:template match="c5"><b><xsl:value-of select="."/></b></xsl:template><xsl:template match="c6"><b><xsl:value-of select="."/></b></xsl:template><xsl:template match="c7"><b><xsl:value-of select="."/></b></xsl:template><xsl:template match="c8"><b><xsl:value-of select="."/></b></xsl:template><xsl:template match="c9"><b><xsl:value-of select="."/></b></xsl:template><!-- The size attribute for each result is prepared here --><!-- A generic template to display string with non 0 string length (used for author and lastmodified time --><!-- document collapsing link setup --><xsl:template name="DisplayCollapsingStatusLink"><xsl:param name="status"/><xsl:param name="urlEncoded"/><xsl:param name="id"/><xsl:if test="$CollapsingStatusLink"><xsl:choose><xsl:when test="$status=1"><br/><xsl:variable name="CollapsingStatusHref" select="concat(substring-before($CollapsingStatusLink, '$$COLLAPSE_PARAM$$'), 'duplicates:"', $urlEncoded, '"', substring-after($CollapsingStatusLink, '$$COLLAPSE_PARAM$$'))"/><span class="srch-dup">[<a href="{$CollapsingStatusHref}" id="$id" title="{$CollapseDuplicatesText}"><xsl:value-of select="$CollapseDuplicatesText"/></a>]</span></xsl:when></xsl:choose></xsl:if></xsl:template><!-- The "view more results" for fixed query --><xsl:template name="DisplayMoreResultsAnchor"><xsl:if test="$MoreResultsLink"><a href="{$MoreResultsLink}" id="CSR_MRL"><xsl:value-of select="$MoreResultsText"/></a></xsl:if></xsl:template><xsl:template match="All_Results/DiscoveredDefinitions"><xsl:variable name="FoundIn" select="DDFoundIn" /><xsl:variable name="DDSearchTerm" select="DDSearchTerm" /><xsl:if test="$DisplayDiscoveredDefinition = 'True' and string-length($DDSearchTerm) > 0"><script language="javascript">function ToggleDefinitionSelection(){var selection = document.getElementById("definitionSelection");if (selection.style.display == "none"){selection.style.display = "inline";}else{selection.style.display = "none";}}</script><div><a href="#" onclick="ToggleDefinitionSelection(); return false;"><xsl:value-of select="$DefinitionIntro" /><b><xsl:value-of select="$DDSearchTerm"/></b></a><div id="definitionSelection" class="srch-Description" style="display:none;"><xsl:for-each select="DDefinitions/DDefinition"><br/><xsl:variable name="DDUrl" select="DDUrl" /><xsl:value-of select="DDStart"/><b><xsl:value-of select="DDBold"/></b><xsl:value-of select="DDEnd"/><br/><xsl:value-of select="$FoundIn"/><a href="{$DDUrl}"><xsl:value-of select="DDTitle"/></a></xsl:for-each></div></div></xsl:if></xsl:template><!-- XSL transformation starts here --><xsl:template match="/"><xsl:if test="$AlertMeLink"><input type="hidden" name="P_Query" /><input type="hidden" name="P_LastNotificationTime" /></xsl:if><xsl:choose><xsl:when test="$IsNoKeyword = 'True'" ><xsl:call-template name="dvt_1.noKeyword" /></xsl:when><xsl:when test="$ShowMessage = 'True'"><xsl:call-template name="dvt_1.empty" /></xsl:when><xsl:otherwise><xsl:call-template name="dvt_1.body"/></xsl:otherwise></xsl:choose></xsl:template><!-- End of Stylesheet --></xsl:stylesheet>
  5. <xsl:value-of select="count(./@*)"/>
  6. When you use <xsl:value-of select="title"/> you are only pulling in the text - not processing the nodes. Try: <xsl:apply-templates select="title"/>
  7. Here is one way without using multiple passes on the file. <xsl:template match="text()"><xsl:choose><xsl:when test="contains(.,'<CreditCardNumber>')"><!-- This is the CDATA that I want to mask and write back out as CDATA --> <xsl:variable name="tcontent"><xsl:value-of select="substring-after(substring-before(.,'</CreditCardNumber>'),'<CreditCardNumber>') "/> </xsl:variable> <xsl:text disable-output-escaping="yes"><![CDATA[<CreditCardNumber></xsl:text> <xsl:call-template name="maskVariable"> <xsl:with-param name="tvar" select="$tcontent"/> </xsl:call-template> <xsl:text disable-output-escaping="yes"></CreditCardNumber>]]></xsl:text></xsl:when><xsl:otherwise> <xsl:copy/></xsl:otherwise></xsl:choose></xsl:template> <xsl:template name="maskVariable"> <xsl:param name="tvar"/> <xsl:variable name="length" select="string-length($tvar)"/> <xsl:choose> <xsl:when test="$length > 3"> <xsl:value-of select="concat ('************', substring($tvar,$length - 1, 2))"/> </xsl:when> <xsl:when test="$length > 1">***</xsl:when> <xsl:otherwise/> </xsl:choose></xsl:template>
  8. That didn't post correctly. Here it is again: <xsl:output method="xml" cdata-section-elements="GetAmountDueResult"/> <xsl:template match="GetAmountDueResult"><xsl:copy><xsl:value-of disable-output-escaping="yes" select="."/></xsl:copy></xsl:template >
  9. Try this: [/size][size="2"] <xsl:output method="xml" [font="Courier New"][size="2"][font="Courier New"][size="2"]cdata-section-elements="GetAmountDueResult"[/size][/font][/size][/font][size="2"]/>[/size][/size][size="2"] <xsl:template match="GetAmountDueResult"><xsl:copy><xsl:value-of disable-output-escaping="yes" select="."/></xsl:copy></xsl:template >[/size][size="2"]
  10. I would use a recursive template but I'd love to see how others might do this. <xsl:template match="avg"/><xsl:template name="findAverage"> <xsl:param name="numlessons"/> <xsl:param name="pointer"/> <xsl:param name="total"/> <xsl:choose> <xsl:when test="$pointer <= $numlessons"> <xsl:variable name="subtotal"> <xsl:value-of select="child::*[number($pointer)]"/> </xsl:variable> <xsl:variable name="total"> <xsl:value-of select="number($subtotal) + number($total)"/> </xsl:variable> <xsl:call-template name="findAverage"> <xsl:with-param name="numlessons" select="$numlessons"/> <xsl:with-param name="pointer" select="$pointer + 1"/> <xsl:with-param name="total" select="$total"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <!-- Divide total by numlessons --> <xsl:value-of select="$total div $numlessons"/> </xsl:otherwise> </xsl:choose></xsl:template><xsl:template match="lessons"> <xsl:variable name="numlessons"> <xsl:value-of select="count(child::*)"/> </xsl:variable> <xsl:variable name="xaverage"> <xsl:call-template name="findAverage"> <xsl:with-param name="numlessons" select="$numlessons"/> <xsl:with-param name="pointer" select="1"/> <xsl:with-param name="total" select="0"/> </xsl:call-template> </xsl:variable> <xsl:element name="lessons"> <xsl:apply-templates/> </xsl:element> <xsl:text></xsl:text> <xsl:element name="avg"> <xsl:value-of select="$xaverage"/> </xsl:element></xsl:template>
  11. If your input looks like this: <database><Record><Field ID="8131"><Value>1. Primary</Value></Field><Field ID="8132"><Value>Robert Crane</Value></Field></Record><Record><Field ID="8131"><Value>2. Secondary</Value></Field><Field ID="8132"><Value>David Willis</Value></Field></Record><Record><Field ID="8131"><Value>2. Secondary</Value></Field><Field ID="8132"><Value>Mary Jones</Value></Field></Record><Record><Field ID="8131"><Value>1. Primary</Value></Field><Field ID="8132"><Value>Ben Smith</Value></Field></Record></database> and style sheet like this: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"><xsl:output method="html"/><xsl:template match="database"> <table> <tbody> <tr> <th>Type</th> <th>Name</th> </tr> <xsl:for-each select="Record"> <xsl:sort select="Field[@ID='8131']"/> <xsl:sort select="Field[@ID='8132']"/> <xsl:apply-templates select="."/> </xsl:for-each> </tbody> </table></xsl:template><xsl:template match="Record"> <tr> <xsl:apply-templates/> </tr></xsl:template><xsl:template match="Field"> <xsl:choose> <xsl:when test="@ID='8131'"> <td> <xsl:apply-templates/> </td> </xsl:when> <xsl:when test="@ID='8132'"> <td> <xsl:apply-templates/> </td> </xsl:when> </xsl:choose></xsl:template><xsl:template match="*"> <xsl:element name="{name()}"> <xsl:apply-templates/> </xsl:element></xsl:template></xsl:stylesheet> Your output will be double sorted liked this: <table><tbody> <tr> <th>Type</th> <th>Name</th> </tr> <tr> <td> <Value>1. Primary</Value> </td> <td> <Value>Ben Smith</Value> </td> </tr> <tr> <td> <Value>1. Primary</Value> </td> <td> <Value>Robert Crane</Value> </td> </tr> <tr> <td> <Value>2. Secondary</Value> </td> <td> <Value>David Willis</Value> </td> </tr> <tr> <td> <Value>2. Secondary</Value> </td> <td> <Value>Mary Jones</Value> </td> </tr></tbody></table>
  12. The file can be converted to nested xml easier with non-xml based tools like perl and flex (in my opinion). However, if you must use XSLT here is what I use to convert a database file to html. Input File <database><H1>Title 1</H1><para>Para 1</para><para>Para 2</para><para>Para 3</para><H2>Title 2</H2><para>Para 1</para><para>Para 2</para><H2>Title 2</H2><para>Para 1</para><para>Para 2</para><H3>Title 3</H3><para>Para 1</para><para>Para 2</para><H1>Title 1</H1><para>Para 1</para><para>Para 2</para><H3>Title 3</H3><para>Para 1</para><para>Para 2</para><H1>Title 1</H1><para>Para 1</para><para>Para 2</para><H3>Title 3</H3><para>Para 1</para><para>Para 2</para><H1>Title 1</H1><para>Para 1</para><para>Para 2</para><H2>Title 2</H2><para>Para 1</para><H3>Title 3</H3><para>Para 1</para><H2>Title 2</H2><para>Para 1</para></database> Style Sheet <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"><xsl:output method="xml"/><xsl:template match="database"> <xsl:element name="html"> <xsl:for-each select="*"> <xsl:choose> <xsl:when test="name()='H1' "> <xsl:call-template name="H1"/> </xsl:when> <xsl:when test="name()='H2' "> <xsl:call-template name="H2"/> </xsl:when> <xsl:when test="name()='H3'"> <xsl:call-template name="H3"/> </xsl:when> <xsl:otherwise> <xsl:call-template name="fallthru"/> </xsl:otherwise> </xsl:choose> <xsl:if test="position()=last()"> <!-- close open levels --> <xsl:variable name="level"> <xsl:call-template name="whatLevel"> <xsl:with-param name="pointer" select="1"/> </xsl:call-template> </xsl:variable> <xsl:choose> <xsl:when test="$level = 'H1' "> <xsl:text disable-output-escaping="yes"></div></xsl:text> </xsl:when> <xsl:when test="$level = 'H2' "> <xsl:text disable-output-escaping="yes"></div></xsl:text> <xsl:text disable-output-escaping="yes"></div></xsl:text> </xsl:when> <xsl:when test="$level = 'H3' "> <xsl:text disable-output-escaping="yes"></div></xsl:text> <xsl:text disable-output-escaping="yes"></div></xsl:text> <xsl:text disable-output-escaping="yes"></div></xsl:text> </xsl:when> <xsl:otherwise> <xsl:text disable-output-escaping="yes"></div></xsl:text> </xsl:otherwise> </xsl:choose> </xsl:if> </xsl:for-each> </xsl:element></xsl:template><xsl:template name="whatLevel"> <xsl:param name="pointer"/> <xsl:if test="$pointer < 10"> <xsl:choose> <xsl:when test="name(preceding-sibling::*[number($pointer)]) = ''"/> <xsl:when test="name(preceding-sibling::*[number($pointer)]) = 'H1'">H1</xsl:when> <xsl:when test="name(preceding-sibling::*[number($pointer)]) = 'H2'">H2</xsl:when> <xsl:when test="name(preceding-sibling::*[number($pointer)]) = 'H3'">H3</xsl:when> <xsl:otherwise> <xsl:call-template name="whatLevel"> <xsl:with-param name="pointer"> <xsl:value-of select="$pointer + 1"/> </xsl:with-param> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:if></xsl:template><xsl:template match="H1" name="H1"> <xsl:variable name="level"> <xsl:call-template name="whatLevel"> <xsl:with-param name="pointer" select="1"/> </xsl:call-template> </xsl:variable> <xsl:choose> <xsl:when test="$level = 'H1' "> <xsl:text disable-output-escaping="yes"></div></xsl:text> </xsl:when> <xsl:when test="$level = 'H2' "> <xsl:text disable-output-escaping="yes"></div></xsl:text> <xsl:text disable-output-escaping="yes"></div></xsl:text> </xsl:when> <xsl:when test="$level = 'H3' "> <xsl:text disable-output-escaping="yes"></div></xsl:text> <xsl:text disable-output-escaping="yes"></div></xsl:text> <xsl:text disable-output-escaping="yes"></div></xsl:text> </xsl:when> </xsl:choose> <xsl:text disable-output-escaping="yes"><div class="div1"></xsl:text> <xsl:element name="th"> <xsl:apply-templates/> </xsl:element></xsl:template><xsl:template match="H2" name="H2"> <!-- go backward through siblings to see what last title was --> <xsl:variable name="level"> <xsl:call-template name="whatLevel"> <xsl:with-param name="pointer" select="1"/> </xsl:call-template> </xsl:variable> <xsl:choose> <xsl:when test="$level = 'H3'"> <xsl:text disable-output-escaping="yes"></div></xsl:text> <xsl:text disable-output-escaping="yes"></div></xsl:text> </xsl:when> <xsl:when test="$level = 'H2'"> <xsl:text disable-output-escaping="yes"></div></xsl:text> </xsl:when> </xsl:choose> <xsl:text disable-output-escaping="yes"><div class="div2"></xsl:text> <xsl:element name="th"> <xsl:apply-templates/> </xsl:element></xsl:template><xsl:template match="H3" name="H3"> <!-- go backward through siblings to see what last title was --> <xsl:variable name="level"> <xsl:call-template name="whatLevel"> <xsl:with-param name="pointer" select="1"/> </xsl:call-template> </xsl:variable> <xsl:choose> <xsl:when test="$level = 'H3'"> <xsl:text disable-output-escaping="yes"></div></xsl:text> </xsl:when> </xsl:choose> <xsl:if test="$level='H1'"> <xsl:text disable-output-escaping="yes"><div class="div2"></xsl:text> </xsl:if> <xsl:text disable-output-escaping="yes"><div class="div3"></xsl:text> <xsl:element name="th"> <xsl:apply-templates/> </xsl:element></xsl:template><xsl:template match="para"> <xsl:element name="p"> <xsl:apply-templates/> </xsl:element></xsl:template><xsl:template match="*" name="fallthru"> <xsl:element name="{name()}"> <xsl:apply-templates/> </xsl:element></xsl:template></xsl:stylesheet> Output File <?xml version="1.0" encoding="UTF-8"?><html><div class="div1"> <th>Title 1</th> <para>Para 1</para> <para>Para 2</para> <para>Para 3</para> <div class="div2"> <th>Title 2</th> <para>Para 1</para> <para>Para 2</para> </div> <div class="div2"> <th>Title 2</th> <para>Para 1</para> <para>Para 2</para> <div class="div3"> <th>Title 3</th> <para>Para 1</para> <para>Para 2</para> </div> </div></div><div class="div1"> <th>Title 1</th> <para>Para 1</para> <para>Para 2</para> <div class="div2"> <div class="div3"> <th>Title 3</th> <para>Para 1</para> <para>Para 2</para> </div> </div></div><div class="div1"> <th>Title 1</th> <para>Para 1</para> <para>Para 2</para> <div class="div2"> <div class="div3"> <th>Title 3</th> <para>Para 1</para> <para>Para 2</para> </div> </div></div><div class="div1"> <th>Title 1</th> <para>Para 1</para> <para>Para 2</para> <div class="div2"> <th>Title 2</th> <para>Para 1</para> <div class="div3"> <th>Title 3</th> <para>Para 1</para> </div> </div> <div class="div2"> <th>Title 2</th> <para>Para 1</para> </div></div></html>
  13. Consider passing both the string and the node-set to your mark-up template. (XSLT 2 only) If you need to use XSLT 1.0, you can use the exsl:node-set function. <xsl:template name="List" match="li"> <xsl:variable name="lnodes"> <li><xsl:copy-of select="node()"/></li></xsl:variable> <xsl:call-template name="markup"> <xsl:with-param name="text" select="."/> <xsl:with-param name="phrases" select="document('../../documents/main/keywords.xml')/keywords/keyword"/> <xsl:with-param name="first-only" select="false()"/> <xsl:with-param name="nodes" select="$lnodes"/> </xsl:call-template> </xsl:template> Now in your markup template you have the variable $text with the string "Make this bold" to compare for keywords and the nodes to print out when time. <xsl:apply-templates select="$lnodes"/> I hope that makes sense.
  14. Have you tried <fo:block-container> with reference-orientation attribute?
  15. You could do it this way: <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/> <xsl:template match="/"> <xsl:apply-templates select="//prime"/></xsl:template> <xsl:template match="prime"> <xsl:apply-templates select="note"/></xsl:template> <xsl:template match="note"> <xsl:choose> <xsl:when test="@style='tt'"> <xsl:apply-templates mode="tt"/> </xsl:when> <xsl:when test="@style='sms'"> <xsl:apply-templates mode="sms"/> </xsl:when> </xsl:choose></xsl:template><xsl:template match="note/rss/channel" mode="tt"> <xsl:apply-templates select="item" mode="tt"></xsl:template><xsl:template match="note/rss/channel" mode="sms"> <xsl:apply-templates select="item" mode="sms"></xsl:template><xsl:template match="item" mode="tt"><item> <title> <xsl:value-of select="title"/> </title> <description> <xsl:value-of select="description"/> </description> <pubDate> <xsl:value-of select="pubDate"/> </pubDate></item></xsl:template><xsl:template match="item" mode="sms"><item> <title> <xsl:value-of select="title"/> </title> <pubDate> <xsl:value-of select="pubDate"/> </pubDate></item></xsl:template> </xsl:stylesheet>
×
×
  • Create New...