Subject: RE: [xsl] Writing a stylesheet to create a stylesheet, with XSLT in the XML From: Scott Moore <Scott.Moore@xxxxxxxxxxxxx> Date: Mon, 17 Jun 2002 18:34:00 -0400 |
> Why? > > I'm asking rhetorically; it's generally a bad idea to try to embed > markup as character data, and then expect it to be markup upon output. Okay, you asked... I'm doing it because I need to create a stylesheet from a stylesheet. That stylesheet then creates XSL-FO, which is used to create a PDF. Our customers need to control the layout of the report, which is handled by the original XML file, which is transformed into a driver stylesheet, that is used to create the XSL-FO. Now, a new requirement comes in where we need to flexibly allow a combination of static text and dynamic values in the XML creating the report (not the driver stylesheet) to be in the header and footer of the report. The content of the header/footer would be controlled thru the original XML layout file, which creates the report stylesheet. In order to be flexible, I wanted to embed XSL markup in the "label" attribute. > > Ah, but it doesn't. It produces in the result *tree* a single > text node > containing the pseudo-markup > < x s l : v a l u e - o f > and so on, with spaces added to emphasize that it's character data. > > If you intend to produce <xsl:value-of...> in the *serialization* > of the result tree, then you must have not a text node but an > element node > with this structure: Yes, I realize that. The result tree is *serialized* to a file, which is then used as a stylesheet by the system later on. Therefore, the text node becomes markup. > > element named 'value-of' in namespace > 'http://www.w3.org/1999/XSL/Transform' > \___attribute 'select' with value '/Doc/FirstName' > > So, why not have > > <Sections> > <label> > <xsl:value-of select="/Doc/FirstName"/> > </label> > </Sections> Because it violates the schema of our XML file. The label is by far the easier approach. Adding an element like that would break too many pieces of the system. However, I've worked around the problem by delineating XPaths with special characters, so I can specify static and dynamic text in the attribute without having to use markup. I now have a recursive string template that picks out the pieces and creates the result tree correctly. Thanks for all the feedback, Scott XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] selecting an element in a, Michael Kay | Thread | [xsl] Template priority, Brian Grainger |
Re: [xsl] cocoon or xalan, Steven Noels | Date | Re: [xsl] Re: sorting, Joerg Heinicke |
Month |