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)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Steve GlanzelSubject: Conditional processing nodes at the same level
Author: Steve Glanzel
Date: 17 Dec 2004 08:59 AM
I have attached a snippet of an XML file created from rich text. The rich text contains a mixture of paragraphs and bullet pointed paragraphs. What I want to do is transform the rich text file while preserving the same formatting, etc.

I am using the same schemas for both ends of the transform and know the paragraphs (contained in the <par> tags) are bulleted when their def attribute equals 11 and continue to be bulleted until the next <par> tag at that node level has a def attribute other than 11.

In functional programming terms the obvious thing to use would be an xls:if select='@def='11' followed by an "for-each", processing any subsequent <par> tags and then breaking when def!="", but with XSLT I can't do this. And I can't use the node list because the <par(s)> I want to bullet are at the same node level and only differentiated by their def attribute.

Would any one be able to suggest a possible alternative(s), etc I could take.

Thanks for any help!


<par def="10">
<run html="false" highlight="none" readingorder="lefttoright">
<font style="bold" />
The Panel will publish information in accordance with the scheme and shall
monitor and review its operation. Please note:
</run>
</par>
<par def="11">
this will be a living document, which will be modified and developed in light of public comment and feedback;
</par>
<par>
sometimes, information may not be provided and the reasons will be given in each instance.
</par>
<par>
[this scheme is not retrospective, and we do not undertake to publish information held by RPA which was generated before 31 December 2003, the date the Scheme came into force];
</par>
<par>information retention periods can vary from class to class.</par>
<par def="6" />
<par>If you have an enquiry about a specific information source, please contact:</par>
<par def="10" />
<par>Customer Relations Unit (CRU)</par>
<par>PO Box 69, Reading,</par>
<par>RG1 3YD,</par>


Postnext
James DurningSubject: Conditional processing nodes at the same level
Author: James Durning
Date: 17 Dec 2004 05:29 PM
Originally Posted: 17 Dec 2004 12:37 PM
Perhaps you could check backwards? test="(@def = 11) or ((not @def) and (preceding-sibling::par[@def]/@def=11))"

Posttop
Ivan PedruzziSubject: Conditional processing nodes at the same level
Author: Ivan Pedruzzi
Date: 17 Dec 2004 03:24 PM
Hi Steve

The following method is one of the possible solutions;


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head/>
<body><xsl:apply-templates select="root/par[1]"/></body>
</html>
</xsl:template>

<xsl:template match="par[@def!='11' and @def]">
<p><xsl:copy-of select="."/></p>
<xsl:apply-templates select="following-sibling::par[1]"/>
</xsl:template>

<xsl:template match="par[@def='11']">
<ul>
<li><p><xsl:copy-of select="."/></p></li>
<xsl:apply-templates select="following-sibling::par[1]" mode="bulleted"/>
</ul>
<xsl:apply-templates select="following-sibling::par[@def][1]"/>
</xsl:template>

<xsl:template match="par[not(@def)]" mode="bulleted">
<li><p><xsl:copy-of select="."/></p></li>
<xsl:apply-templates select="following-sibling::par[1][not(@def)]" mode="bulleted"/>
</xsl:template>

<xsl:template match="par[not(@def)]">
<p><xsl:copy-of select="."/></p>
<xsl:apply-templates select="following-sibling::par[1]"/>
</xsl:template>

</xsl:stylesheet>

   
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.