newbie XSLT question

sixstringdork

Usenet Archive
Joined
Jul 9, 2007
Messages
2
Reaction score
0
I'm new to XML/XSLT. I have most of my transform working, but I have some data enclosed with "edit" tags that need to be used to control what HTML gets displayed. Here's a snippet of my XML:

<?xml version="1.0" encoding="iso-8859-1"?>
<rootCode>
<rootCodeTitle startDate='19781001'
endDate='99999999'><title>Chocolate Milk</title>
<chapter><title>CHAPTER 1. GENERAL PROVISIONS</title> <subsec1><title>102. Rules of construction</title> <subsec2> <para>In this title</para> <subsec3> <title>(7)</title> <para>the cow jumped over the moon;<edit startDate='19791001' endDate='19861125'>and</edit><edit startDate='19861126' endDate='99999999'></edit></para> </subsec3> <subsec3> <title>(8)</title> <para>the house, <edit startDate='19701001' endDate='19831002'>continued</edit><edit startDate='19831002' endDate='99999999'>contained</edit> a glass of milk<edit startDate='19701001' endDate='19851125'>.</edit><edit startDate='19851126' endDate='99999999'>; and</edit></para> </subsec3> <subsec3 startDate='19851126' endDate='99999999'><title >(9)</ title> <para>When to shake the jug.</para> </subsec3> </subsec2> </subsec1> </chapter> </rootCodeTitle> </rootCode>

I'm passing an XSL parameter such as code_rev_date = '19800101' (a date converted to a number). I want to display the text as it existed on that date (the parameter date).

So I want to show, for example, most of /subsec3/para, but omit the text that came after 19831002 (based on a parameter of 19800101. I've been drifting around on W3.org, etc. for several days and I'm not having much luck on how to approach this.

I hope this make sense. I can post my XSL sheet, but I don't think it will be much help since it sucks. (using classic ASP and IIS if it matters)

Thanks and sorry for the newbie question.
 

Joe Kesselman

Usenet Archive
Joined
Feb 3, 2006
Messages
1,229
Reaction score
0
Start with the identity stylesheet. (Look in the XSLT spec, or websearch to find a copy of this; it's a near-universal starting point for writing XSLT stylesheets.)

Modify it by adding a template which matches on elements which have a @startDate after, or an @endDate before, the date you're interested in, and which generates no output (thus discarding those elements and all their contents).

Or am I misunderstanding your question?
 

sixstringdork

Usenet Archive
Joined
Jul 9, 2007
Messages
2
Reaction score
0
That's it. Thanks. I have it half way there now. My sheet drops the stuff that falls outside of the relevant dates, but I'm trying to get the formatting right on what's left. I REALLY feel stupid with this stuff. I've been writing .asp code for almost 10 years and am really comfortable doing it, but my brain is seriously broken when it comes to this XSLT stuff (maybe I'm just getting old).

This isn't really a question. Just a thanks to let you know that I got your message and that it helped moved me forward. My real problem, I think, is that I'm trying to learn XML AND XSLT at the same time. I just need to slow down and do some real reading I think. It's just my nature to slog through code until I learn something.

Thanks.
:)
 

Joseph Kesselman

Usenet Archive
Joined
Feb 3, 2006
Messages
733
Reaction score
0
I've been writing .asp code for almost 10 years and am really comfortable doing it, but my brain is seriously broken when it comes to this XSLT stuff (maybe I'm just getting old).

Rule-based programming does seem to be hard for folks to learn... but it's a really powerful idiom once you get used to it.
I think, is that I'm trying to learn XML AND XSLT at the same time. I just need to slow down and do some real reading I think.

Being thrown into the deep end of the pool sometimes works; depends on how good you are at reading other programmers' minds, and how good you are at researching the problems as you encounter them.

Remember to have fun... <smile/>
 

Peter Flynn

Usenet Archive
Joined
Jan 2, 2000
Messages
1,813
Reaction score
0
I'm new to XML/XSLT. I have most of my transform working, but I have some data enclosed with "edit" tags that need to be used to control what HTML gets displayed. Here's a snippet of my XML:

<?xml version="1.0" encoding="iso-8859-1"?>
<rootCode>
<rootCodeTitle startDate='19781001'
endDate='99999999'><title>Chocolate Milk</title>
<chapter><title>CHAPTER 1. GENERAL PROVISIONS</title>
<subsec1><title>102. Rules of construction</title>
<subsec2>
<para>In this title</para>
<subsec3>
<title>(7)</title>
<para>the cow jumped over the moon;<edit startDate='19791001' endDate='19861125'>and</edit><edit startDate='19861126' endDate='99999999'></edit></para> </subsec3> <subsec3> <title>(8)</title> <para>the house, <edit startDate='19701001' endDate='19831002'>continued</edit><edit startDate='19831002' endDate='99999999'>contained</edit> a glass of milk<edit startDate='19701001' endDate='19851125'>.</edit><edit startDate='19851126' endDate='99999999'>; and</edit></para> </subsec3> <subsec3 startDate='19851126' endDate='99999999'><title >(9)</ title> <para>When to shake the jug.</para> </subsec3> </subsec2> </subsec1> </chapter> </rootCodeTitle> </rootCode>

I'm passing an XSL parameter such as code_rev_date = '19800101' (a date converted to a number). I want to display the text as it existed on that date (the parameter date).

I hate to pour cold water on this, but this type of requirement has been solved in other ways long ago, notably with DocBook's effectivity attributes and with numerous historical synchronisation and layering methods developed for the TEI DTD.

///Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,050
Messages
3,104,249
Members
248,133
Latest member
DujonT

Latest Threads

Top