XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Getting xsl element in javascr... (3)
-> + The document() function inside... (3)
-> + Footnote text move to para (2)
-> + XSL: multiple element come to ... (3)
-> - How to use following-sibling &... (2)
-> ->How to use following-sibl...
-> + How to use FOP 0.95 with Stylu... (4)
-> + Error during creating PDF from... (2)
-> + Help creating a comma delimite... (4)
-> + Selective Add using XSLT recur... (3)
-> + Help: convert without parent e... (2)
-> - Correct my substring function ... (1)
-> + Old xsl into reports (4)
-> + How to save xslt converted fil... (3)
-> + How to find non tagging text? (5)
-> + Help: Hex entity to Character... (6)
-> + EDI QUOTES MESSAGE NEED TO REP... (2)
-> + How to convert in multi level ... (4)
-> + Need some help with a styleshe... (3)
-> - Conditional Formattinf Formula... (1)
-> + Creating HTML Unordered LIsts.... (2)
-- Previous [361-380] [381-400] [401-420] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Selva GaneshSubject: How to use following-sibling & starts-with function
Author: Selva Ganesh
Date: 09 May 2009 05:58 AM
I heartly appreciate
I have 3 question:
1. following-sibling function not working in the “si – docid” attribute
2. starts-with function not working in “laid” element
3. choose method want correct (I need single dates element) in my xsl repeated the <dates>
This is my XSL:

<xsl:template match="div[@class='DocContainer']">
<xsl:element name="si">
<xsl:attribute name="docid"><xsl:value-of select="following-sibling::div[@class ='LegPrelims']/h1[@class = 'LegNo'][1]" /></xsl:attribute>
<xsl:attribute name="type"><xsl:text>reg</xsl:text></xsl:attribute>
<xsl:apply-templates></xsl:apply-templates></xsl:element></xsl:template>
<xsl:template match="title"/>
<xsl:template match="style"/>
<xsl:template match="div[@class[.='LegPrelims']]">
<si-begin>
<xsl:apply-templates></xsl:apply-templates>
</si-begin>
</xsl:template>
<xsl:template match="h1">
<xsl:element name="si-nos" >
<xsl:element name="si-year" ><xsl:value-of select="substring-before(., ' ')"/></xsl:element>
<si-no><xsl:value-of select="substring-after(., '. ')"/></si-no></xsl:element>
</xsl:template>
<xsl:template match="div[@class[.='LegDate']]">
<dates>
<xsl:choose>
<xsl:when test="p='Made'">
<xsl:element name="made"><xsl:attribute name="date">
<xsl:value-of select="p[@class[.='LegDateDate']]"/></xsl:attribute>
<xsl:value-of select="p[@class[.='LegDateText']]"/></xsl:element></xsl:when>
<!--<xsl:when test="(starts-with(p, 'Laid'))">-->
<xsl:when test="p='Laid before Parliament'">
<xsl:element name="laid"><xsl:attribute name="date">
<xsl:value-of select="p[@class[.='LegDateDate']]"/></xsl:attribute>
<xsl:value-of select="p[@class[.='LegDateText']]"/></xsl:element></xsl:when>
<xsl:otherwise>
<xsl:element name="in-force"><xsl:element name="in-force-text"><xsl:attribute name="date">
<xsl:value-of select="p[@class ='LegDateDate']"/></xsl:attribute>
<xsl:value-of select="p[@class[.='LegDateText']]"/></xsl:element></xsl:element>
</xsl:otherwise>
</xsl:choose>
</dates>
</xsl:template>

This my input:
<div id="ContentMain"><div class="DocContainer"><div class="LegPrelims">
<h1 class="LegNo">2009 No. 1023</h1>
<p class="LegSubject">Excise</p>
<h1 class="LegTitle">The Excise </h1>
<div class="LegDate">
<p class="LegDateText">Made</p><p class="LegDateDate">22nd April 2009</p>
</div>
<div class="LegDate">
<p class="LegDateText">Laid before Parliament</p><p class="LegDateDate">22nd April 2009</p>
</div>
<div class="LegDate">
<p class="LegDateText">Coming into force</p><p class="LegDateDate">1st June 2009</p>
</div>

</div>
</div>
</div>

This is expected output

<si docid="s2009no815" type="reg">
<si-begin>
<si-nos>
<si-year>2009</si-year>
<si-no>815</si-no>
</si-nos>
<subject>
<subject-text>EXCISE</subject-text>
</subject>
<ti al="c">The Excise</ti>
<dates>
<made date="20090422">Made</made>
<laid date="20090422">Laid before Parliament</laid>
<in-force date="20090601"><in-force-text>Coming into force</in-force-text>
</in-force>
</dates>

</si-begin>
</si>

Posttop
James DurningSubject: How to use following-sibling & starts-with function
Author: James Durning
Date: 13 May 2009 10:55 AM
1. The node is a child node, not a sibling.
Replace
following-sibling::div
with
div

2. Seems to be working when you comment in that code.

3. I suggest making a template to convert the dates from one format to another. Use substring-before and substring-after to get the parts of the date.

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.