Cluttering up the XML with tons of PIs seems at least as inconvenient as
cluttering up a DTD with conditional elements. Is there no existing
element/attribute combination, such as <span>, in the DTD that could serve this
purpose? Alternatively, if you have control over the DTD, you could add an
element/attribute with the allowable values normal/special.
So for example:
<p>Mary had a little <span class="normal">lamb</span><span
class="special">pony</span>...</p>
Or
<p>Mary had a little <text cond="normal">lamb</text><text
cond="special">pony</text>...</p>
Then you'd just suppress either the normal or the special text, whichever you
wanted to output, when you process. This would only require one pass, yes? Or
am I over-simplifying?
Michele
-----Original Message-----
From: Craig Sampson [mailto:Craig(_dot_)Sampson(_at_)sas(_dot_)com]
Sent: Tuesday, June 12, 2012 4:39 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Implementing Conditional Text
Hello,
We, our publications XML support group, are being asked to support conditional
text in our source documents.
We've come up with an idea but before going any further I thought I'd run it by
this group to see if anyone had done this before or if anyone had a better
solution.
We plan to use processing-instructions (PIs) entered by the authors that would
indicate which conditions were on or off. These PIs would be inserted near the
top of the documents. There would be additional PIs identifying the beginning
and end of conditional text strings. We would use a XSL transform to preprocess
these documents and convert the PIs into pseudo elements that could then be
processed in a second XSLT preprocessor would keep or discard the strings based
on the conditions set in the PIs at the top of the document. The resulting
document would not have any of the PIs or pseudo elements just the content that
was kept.
We want to use PIs so we don't have to dirty up our DTD with conditional
elements that would be allowed everywhere. I can't think of any way to
eliminate the conversion to pseudo elements which solves the problem of
identifying and controlling the conditional text.
We are not allowing the conditional text to break existing element boundaries
or to be nested within other conditions so the following example should
represent what we're trying to do:
<topic>
<p>Mary had a little <?condStart normal:true?>lamb<?condStop
normal:true?><?condStart special:true?>pony<?condStop special:true?>...</p>
In the example if the PIs at the top of the document set "normal" to "true" and
"special" to "false" then Mary had a little lamb. If both conditions are set
to true then Mary will have both the lamb and the pony.
Can anyone poke holes in this solution or suggest a better way to accomplish
this.
Thanks,
Craig
--------------------------------------------------------------------
Craig R. Sampson SAS Institute Inc. email:
craig(_dot_)sampson(_at_)sas(_dot_)com
XML Technologies SAS Campus Drive phone: (919) 531-7417
Cary, NC. 27513 FAX: (919) 677-4444
--------------------------------------------------------------------
Please consider the environment before printing this email
--~------------------------------------------------------------------
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>
--~--