[XSL-LIST Mailing List Archive Home]
RE: [xsl] code review
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Theresa Devine
> Sent: 20 February 2004 21:08
> Subject: RE: [xsl] code review
> The reason why I used the string replacement is the
> occurrence of the schoolname and other info is unpredictable.
> The text will also change (via an admin tool that I will
> build soon) - this is a beginning of a content management system.
here is an example for structuring your xml data.
No matter what your career aspirations,
<data name="schoolname"/> can help you get there. We offer
programs, taught by working professionals that provide you
with the skills you need for career advancement.
The xslt is then simple template matching, with no recourse to string
functions. Usually when you continue tagging information with xml it
tends to survive new requirements much better, for example how will u
handle versioning, multiple languages, even if these never emerge as
requirements. Its similar to when some people use of CDATA which
obscures the textual content
To participate in meaningful XSLT processing.
Another benefit could be possibly supplying a default value
<data name="schoolname" default="My High School"/>
some consideration when u pass your ## type xml data to some other
process that doesn't know how to specifically handle such tokens. Though
if u markup your data, you could use sax filtering to great effect with
such a structure. I also think you should crack your transform into 2
steps, with the first step getting the data right with replacement
operations and the 2nd step handling the presentation. Don't be afraid
to use external tools, simple find and replace techniques using grep is
faster and more efficient.
One last .02p thought, whenever you have data that references other
data, such as yours, you should think about linking the dependency
directly in the xml instead of XSLT. In other words your data is not
aware of schools, it requires XSLT to complete the textual data...which
is fine, but if this scenario is the case all the time you should decide
A) your textual data is actually more presentational, and if this is the
case embed the xml data in the xslt file itself ( use the empty
document() trick to refer to it ). It's a technique I find useful as I
never have a set of xml content that gets seperated from the
instructions that 'completes' it.
B) use xlink/xpointer to refer to an xml file with the complete list of
schools; your xslt can still be made to handle such a situation.
gl, Jim Fuller
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list