Jump to content

Page Numbering


lukazar

Recommended Posts

Hi,I'm trying to number the lines of multiple paragraphs.For example:

xml<bill>...<para>FOR AN ACT relating to crimes and offenses; to amend sections 28-101,28-201 and 28-932, Revised Statutes Cumulative Supplement, 2004; tochange provision relating to assault by a confined person; to create theoffense of assault...(etc)</para>

I would need xsl code that makes the output look like so...

1	   FOR AN ACT relating to crimes and offenses; to amend sections 2	   28-101, 28-201 and 28-932, Revised Statutes Cumulative3	   Supplement, 2004; to change provision relating to assault by a4	   confined person; to creat the offense of assault...(etc)

Can anyone help me with this? I just getting my feet wet with xsl, anyhelp would be much appreciated. Thanks,Luke

Link to comment
Share on other sites

The way this looks now, it seems impossible.XSLT would need some way that marks a line break like the <br /> in XHTML. I'll see if there's a way, but right now, it seems there isn't. If I don't give a second reply, there truly isn't.

Link to comment
Share on other sites

The tokenize function seems appropriate. You'll just add a <br /> for each token. However, I don't know where/if it's supported nor what exactly to use as a pattern:

fn:tokenize(string,pattern)Example: tokenize("XPath is fun", "\s+")Result: ("XPath", "is", "fun")
Link to comment
Share on other sites

The tokenize function seems appropriate. You'll just add a <br /> for each token. However, I don't know where/if it's supported nor what exactly to use as a pattern:
Ok thanks I'll play around with it a bit. I have another question which I hope is easier :) Is is possible to indent a para every odd line....so for example:
				  This line is odd and is indentedThis line is even and not indented				 This line is odd and is indented...

Thanks

Link to comment
Share on other sites

If you have some sort of markup in the output, you can always use the CSS property text-indent for it, but without markup in the output, I think it's impossible.

Link to comment
Share on other sites

Hmmm...I was told this verbatim:"first off, you'll need to do a translation of the xml to get line numbering, no way around it. It's really not that difficult to do, just word wrap and count. ... Create a new DTD for printing, then take the XML, pull all the information out and put it into a new XML file, then run the translation to print on the new XML"Is what he saying possible or correct? I've been reading as much as I can find on this, and I haven't gotten anywhere because I haven't found anything!Perhaps I just haven't found a good resource yet. Does anyone know of a good tutorial to do XML to XML using a new DTD?I'm sorry if my questions don't make any sense, it seems the more I get into xml the more confused I get :) Thanks

Link to comment
Share on other sites

I'm not sure I understand the transformational idea correctly, but that "new DTD" stuff is totally wrong. Validating XML documents is optional.You can use DTD, or Schema (or RelaxNG btw) to define legal building blocks of an XML document but that's completely irrelevant to the transformation part. Validating against your own DTD is a good thing, but only when your XML is not only going to be used by you and/or a single application.The same tokenize function I gave example of can turn substrings into text nodes. This is turns means you should be able to apply a markup around each token. This markup can be an ordered list for example with numbers...). Then with CSS you can style each token, say apply indention, etc.However, as I said, this function is not widely supported (if actually supported anywhere), so there is a need for an alternative method. If I understand correctly, what the quote you gave suggests is to first translate the XML into another XML with markup around each row. An XSLT that will turn

<para>FOR AN ACT relating to crimes and offenses; to amend sections 28-101,28-201 and 28-932, Revised Statutes Cumulative Supplement, 2004; tochange provision relating to assault by a confined person; to create theoffense of assault...(etc)</para>

into

<para><row>FOR AN ACT relating to crimes and offenses; to amend sections 28-101,</row><row>28-201 and 28-932, Revised Statutes Cumulative Supplement, 2004; to</row><row>change provision relating to assault by a confined person; to create the</row><row>offense of assault...(etc)</row></para>

for example. Then, with another XSLT applyed on this new XML, turn each <para> into <ol> and <row> into <li>. With special conditions, you may even place a class attribute in the output, allowing you furthen styling with CSS.What's this about printing though? Are you actually planning to print this data? Up to this point I was expecting it would go into a web page.

Link to comment
Share on other sites

Well, both actually, printing and viewing on the web. We need the documents converted to PDF for a number of reasons. I looked into the tokenizer, and as you said, it is not widely supported.You're correct in the xml to xml tranformation using a new DTD for the new xml file validation. I'm slowly starting to build up code that should accomplish this (I hope). I created a thread here http://w3schools.invisionzone.com/index.php?showtopic=6281 in the hopes of getting help with some syntax or any logic flaws.It seems that to be able to do what I'm trying to do, I need break up the para much like you show in your example. Where in stead of making it ready for XHTML I'd have somthing like:

<para><line number=1>text</line><line number=2>text</line></para>

To accomplish this I belive I need a recursive call and the param to be updated at each call. Again, I the link above shows where I've gotten so far with this idea.Thanks again for your input, it's giving my brain a good ol' kick start.EDITGot it figured out. Thanks for the help!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...