|
Subject: Re: [xsl] range creation From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sat, 19 Nov 2011 08:50:31 -0500 |
Hi guys, My input is <link href="#bib40 #bib41 #bib42 #bib45 #bib40 #bib41 #bib45"/> and <link href="#bib40"/><link href="#bib41"/><link href="#bib42"/><link href="#bib45"/><link href="#bib40"/><link href="#bib41"/><link href="#bib45"/> and I want create a range of numbers, if any three numbers are in sequence as displayed in "Required output".
Any clue is appreciated.
Required Output <a href="#bib40">1</a><a href="#bib41">2</a><a href="#bib42">3</a><a href="#bib45">6</a><a href="#bib40">1</a><a href="#bib41">2</a><a href="#bib45">6</a>. Should be <a href="#bib40">1</a>--<a href="#bib42">3</a>, <a href="#bib45">6</a>, <a href="#bib40"> 1</a>, <a href="#bib41"> 2</a>, <a href="#bib45"> 6</a>.
<p>Range test: <link href="#bib40 #bib41"/><link href="#bib42"/><link href="#bib45"/><link href="#bib40"/><link href="#bib41"/><link href="#bib45"/>.
~/t/ftemp $ cat joga.xml <?xml version="1.0" encoding="UTF-8"?> <component xmlns="http://www.wiley.com/namespaces/wiley"> <p>Range test: <link href="#bib40 #bib41 #bib42 #bib45 #bib40 #bib41 #bib45"/>. This should be 1-3, 6, 1, 2, 6.</p> <p>Range Test: <link href="#bib40"/><link href="#bib41"/><link href="#bib42"/><link href="#bib45"/><link href="#bib40"/><link href="#bib41"/><link href="#bib45"/>. This should be 1-3, 6, 1, 2, 6.</p> <p>Individual test: <link href="#bib40"/>, <link href="#bib41"/>, <link href="#bib45"/>.</p> <p>Range test: <link href="#bib40 #bib41"/><link href="#bib42"/><link href="#bib45"/><link href="#bib40"/><link href="#bib41"/><link href="#bib45"/>. Should this be 1-3, 6, 1, 2, 6?</p> <bibliography style="numbered"> <bib xml:id="bib40">bib1</bib> <bib xml:id="bib41">bib2</bib> <bib xml:id="bib42">bib3</bib> <bib xml:id="bib43">bib4</bib> <bib xml:id="bib44">bib5</bib> <bib xml:id="bib45">bib6</bib> </bibliography> </component> ~/t/ftemp $ ~/t/ftemp $ xslt2 joga.xml joga.xsl <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Link test</title> </head> <body>
<ol>
<p name="bib40">bib1</p>
<p name="bib41">bib2</p>
<p name="bib42">bib3</p>
<p name="bib43">bib4</p>
<p name="bib44">bib5</p>
<p name="bib45">bib6</p>
</ol></body> </html>~/t/ftemp $ ~/t/ftemp $ cat joga.xsl <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:w="http://www.wiley.com/namespaces/wiley" exclude-result-prefixes="w" version="2.0">
<xsl:template match="w:component">
<html>
<head><title>Link test</title></head>
<body><xsl:apply-templates/></body>
</html>
</xsl:template><xsl:template match="distilled-link">
<xsl:for-each select="id(@idref,$doc)">
<!--now positioned at the bibliographic reference ready for processing-->
<a href="#{@xml:id}"><xsl:number/></a>
</xsl:for-each>
</xsl:template><xsl:template match="w:bibliography">
<ol>
<xsl:for-each select="w:bib">
<p name="{@xml:id}"><xsl:apply-templates/></p>
</xsl:for-each>
</ol>
</xsl:template></xsl:stylesheet>~/t/ftemp $ ~/t/ftemp $
-- Contact us for world-wide XML consulting and instructor-led training Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] range creation, Joga Singh Rawat | Thread | RE: [xsl] range creation, Joga Singh Rawat |
| FW: [xsl] range creation, Joga Singh Rawat | Date | RE: [xsl] range creation, Joga Singh Rawat |
| Month |