Re: creating tags around a string
Ordinarily, we don't create "tags" in XSLT. Instead, we use the language's built-in capability to build a structure of nodes that represents ("is") an XML document, and then rely on a downstream component after the transformation (a "serializer") to write tags-and-text -- XML syntax -- that represents ("is") the desired result.
This can be confusing since the way we represent these structures (which we call "trees") in a stylesheet is the same as we do in a document -- using tags and text.
This means that instead of what you have (reformatted for clarity):
<xsl:text><fname></xsl:text> <xsl:value-of select="."/> <xsl:text></fname></xsl:text>
one could simply write
<fname> <xsl:value-of select="."/> </fname>
which would instruct the processor to attach a branch to the tree like this:
+ [element 'fname' + [value of '.'] ]
which is to say an element named 'fname', containing a bit of text (the value of "."). No tags have to be written until the tree to which this branch is attached is built by the transformation, at which point we could simply hand it to the serializer, which for this bit would write "<fname>Bob</fname>" (if our value had been "Bob").
Is there any reason you can't do this?
In contrast, what you have would do this:
+ [text '<fname>'] + [value of '.'] + [text '</fname>']
which is both more work -- think about adding attributes, keeping the nesting right, etc. -- and hard to write, debug and maintain.
If you could build trees instead of write tags-and-text, it would make the rest of what you need to do (handling variant input) much easier, along with everything else.
For everyday purposes, using XSLT to write explicit tags is considered a no-no, since there's almost never a good reason to do it. And no wonder: the other way is how the language is designed to work.
At 05:17 PM 4/17/2006, you wrote:
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format