Subject: RE: [xsl] Applying templates to a mixed content node From: "Passin, Tom" <tpassin@xxxxxxxxxxxx> Date: Tue, 16 Sep 2003 17:09:42 -0400 |
[Ryan Graham] > I have the following source XML (which is formed somewhat awkwardly): > > <p>Some text for the p tag. > <tabular> > <table> > ... > </table> > </tabular> > </p> > > Note that <p> contains both text and other children elements. > In processing, I would like to write the p/text() node to an > FO block, and > then continue to process the <tabular> node with templates. > These xpath > expressions seem evaluate correctly, but the processor never > processes the > <tabular> node: > Using your xml and stylesheet fragment, the "tabular" element _is_ "processed" by the xslt processor. I say that because I just tried it. There are several questions here - 1) Why do you say it does not when it does? 2) Is the way you are going about the task sensible? As to 1), do you mean that there is no output from the xslt processor, or that the result of FO processing is not what you expect? If the former, what xslt processor are you using? As to 2), it is not quite clear to me what you want to do and what your input will be, but your approach does not quite gell. That is partly because you use xsl:apply-templates a second time where it will pick up the "tabular" child element. Thus you will process both the text and the tabular element twice, which is probably not what you want. But several crucial pieces of information are missing, so that we cannot really advise you properly - a) What should happen if there is text but no tabular element? Should the text be emitted anyway? b) Can there be any text after a tabular element, and if so do you want to emit it before or after the tabular element? As an aside, it is redundant to use './' './text()' means the same thing as 'text()', for example. These are not unix path statements. > <xsl:template match="p"> > <xsl:if test="./tabular"> > <fo:block xsl:use-attribute-sets="para"> > <xsl:value-of select="./text()" /> > </fo:block> > <xsl:apply-templates select="tabular"/> > </xsl:if> > <fo:block xsl:use-attribute-sets="para"> > <xsl:apply-templates /> > </fo:block> > </xsl:template> > Ther are many possibilities for simplifying your code and getting it to do just what you want, but we need to know what you want first. Cheers, Tom P XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Applying templates to a m, Michael Kay | Thread | RE: [xsl] Applying templates to a m, Ryan Graham |
[xsl] Applying templates to a mixed, Ryan Graham | Date | RE: [xsl] Problem accessing child n, Dan Sumption |
Month |