Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSL paginator problem

Reply
Thread Tools

XSL paginator problem

 
 
=?ISO-8859-2?Q?=A3ukasz?=
Guest
Posts: n/a
 
      09-02-2004
Hello,
i've short question. How convert this XML:
<doc>
<t1>
...
<t1>
<page-break/>
<t2>
...
<t2>
</doc>

into this:
<doc>
<page>
<t1>
...
<t1>
</page>
<page>
<t2>
...
<t2>
</page>
</doc>

please help!
Luke
 
Reply With Quote
 
 
 
 
Malcolm Dew-Jones
Guest
Posts: n/a
 
      09-02-2004
=?ISO-8859-2?Q?=A3ukasz?= ((E-Mail Removed)) wrote:
: Hello,
: i've short question. How convert this XML:
: <doc>
: <t1>
: ...
: <t1>
: <page-break/>
: <t2>
: ...
: <t2>
: </doc>

: into this:
: <doc>
: <page>
: <t1>
: ...
: <t1>
: </page>
: <page>
: <t2>
: ...
: <t2>
: </page>
: </doc>

: please help!
: Luke

in perl

s% <doc> % <doc><page> %x;
s% </doc> % </page></doc %x;

s% <page-break/> % </page><page> %x;

presumably a similar simple manipulation could be done with xlst, though I
need to read the manual for that which I don't intend to do here.
 
Reply With Quote
 
 
 
 
Marrow
Guest
Posts: n/a
 
      09-02-2004
Hi Luke,

Try something like...

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml" indent="yes"/>
<xsl:template match="doc">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="page-break"/>
</xsl:copy>
</xsl:template>

<xsl:template match="doc/page-break">
<page>
<xsl:variable name="this-id" select="generate-id()"/>
<xsl:apply-templates
select="preceding-sibling::node()[generate-id(following-sibling:age-break)
= $this-id]"/>
</page>
<xsl:if test="not(following-sibling:age-break)">
<page>
<xsl:apply-templates select="following-sibling::node()"/>
</page>
</xsl:if>
</xsl:template>

<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="@* | text() | comment() | processing-instruction()">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>


HTH
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator


"Łukasz" <(E-Mail Removed)> wrote in message
news:ch7c79$rni$(E-Mail Removed)...
> Hello,
> i've short question. How convert this XML:
> <doc>
> <t1>
> ...
> <t1>
> <page-break/>
> <t2>
> ...
> <t2>
> </doc>
>
> into this:
> <doc>
> <page>
> <t1>
> ...
> <t1>
> </page>
> <page>
> <t2>
> ...
> <t2>
> </page>
> </doc>
>
> please help!
> Luke



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Maintaining running values between paginator pages Tim Ruby 3 06-29-2006 02:17 AM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
tomcal/xsl - problems with xsl:include Klaus Friese Java 0 11-22-2004 10:17 AM
XSL-1000: (Fatal Error) Error while parsing XSL file (org.apache.xerces.parsers.AbstractSAXParser$AttributesProxy) Kevin Flood Java 1 09-13-2004 02:28 PM
XSL-1000: (Fatal Error) Error while parsing XSL file (org.apache.xerces.parsers.AbstractSAXParser$AttributesProxy) Kevin Flood Java 0 09-08-2004 02:11 PM



Advertisments