xsl-list
[Top] [All Lists]

Re: [xsl] XSLT transformation using counters

2011-04-27 11:37:58
You seem to have some fairly specific (if incomplete) requirements for
the output, which points to there being some other program or process
that will receive this output.  What is that program or process and
what are its requirements?  Does it need well-formed XML as input, or
something that just "happens to look a little like XML, but not
really"?

-Brandon :)


On Wed, Apr 27, 2011 at 8:32 AM, Bubba O'Reily 
<killswi7ch1(_at_)live(_dot_)com> wrote:



Now I'm confused. Maybe XML output is not the way to go? SHould it be just 
"text"? Bascially I have a well-formed XML file as input. I need to translate 
all the elements to tags using the syntax below (ex. <ParaStyle:SOME_NAME>)

Any <a href="??">...<a/>, <i>...</i> would also require replacing. So I will 
need to replace </ elements to.

What is the best method to perform this task?




Date: Wed, 27 Apr 2011 13:17:37 +0100
From: davidc(_at_)nag(_dot_)co(_dot_)uk
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
CC: killswi7ch1(_at_)live(_dot_)com
Subject: Re: [xsl] XSLT transformation using counters

On 27/04/2011 12:40, Bubba O'Reily wrote:


I want to export XML.

then it would really help people understand your requirements if the
required output that you showed was well formed xml, so far (including
this last mail) that has never been the case. Where do you want your
elements to close?


There are other elements I also neeed to replace in the file.
If I output method="text" then those disappear in the output. For
example<a href="??">...</a>


text output doesn't contain elements, but (the reason I mentioned it) is
that if you are generating text then the string <foo> will be output as
that, not as &lt;foo&gt; so there is no need for disable-output-escaping
(as no escaping happens for plain text). However, if you are generating
xml this is not relevant.


I'm getting alot closer but how do I decrement the counter when a
heading appears outside of a</lev>. See example input, output& code
below. Note the output on the following lines:


XSLT doesn't have counters, If you specify what needs to be counted with
the attributes to xsl:number then the correct number should be output.

<ParaStyle:hd4>Level 3
<ParaStyle:para>para text
<ParaStyle:hd4>Level 2
<ParaStyle:para>para text
<ParaStyle:hd4>Level 1
<ParaStyle:para>para text

The<ParaStyle:hd?> is not correct. I need to decrement the counter
so
when a</lev> occurs the appropriate counter is used.

Should be:

<ParaStyle:hd3>Level 3
<ParaStyle:para>para text
<ParaStyle:hd2>Level 2
<ParaStyle:para>para text
<ParaStyle:hd1>Level 1
<ParaStyle:para>para text




Input:
------

<lev>
<heading>Level 1</heading>
<para>para text</para>
<heading>Level 1A</heading>
<para>para text</para>
<lev>
<heading>Level 2</heading>
<para>para text</para>
<heading>Level 2A</heading>
<para>para text</para>
<heading>Level 2B</heading>
<para>para text</para>
<lev>
<heading>Level 3</heading>
<para>para text</para>
<lev>
<heading>Level 4</heading>
<para>para text</para>
<heading>Level 4A</heading>
<para>para text</para>
<heading>Level 4B</heading>
<para>para text</para>
</lev>
<heading>Level 3</heading>
<para>para text</para>
</lev>
<heading>Level 2</heading>
<para>para text</para>
</lev>
<heading>Level 1</heading>
<para>para text</para>
</lev>




Output Required:
----------------

This output is not well formed and so will generate a fatal error in any
XML tool. It is virtually impossible to generate non well formed XML in
XSLT unless you use disable-output escaping.

If you showed a well formed example of your required output, then
someone could show you how to generate it.



<ParaStyle:lev>
<ParaStyle:hd1>Level 1
<ParaStyle:para>para text
<ParaStyle:hd1>Level 1A
<ParaStyle:para>para text


David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--