This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: HTML in XML not getting to my html output.


try this:

<xsl:template name="separated-list">
	<xsl:param name="nodes"/>
	<xsl:param name="separator"/>
	<xsl:for-each select="$nodes">
		<xsl:apply-templates />
		<xsl:if test="position() != last()">
			<xsl:copy-of select="$separator"/>
		</xsl:if>
	</xsl:for-each>
</xsl:template>

<xsl:template match="node()">
  <xsl:copy>
  	<xsl:copy-of select="@*" />
	<xsl:apply-templates />
  </xsl:copy>
</xsl:template>

<xsl:template match="text()" priority="1">
  <xsl:value-of select="normalize-space(.)" />
</xsl:template>


-----Original Message-----
From: owner-xsl-list@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Robert
Nicholson
Sent: Saturday, April 21, 2001 9:22 PM
To: xsl-list@lists.mulberrytech.com
Subject: RE: [xsl] HTML in XML not getting to my html output.


Thanks for you all your help...

It's interesting that I cannot use normalize space I had be using it because
my source xml looks like this

			<note>
				<b><i>Please note that I am a British and Australian citizen who is a
				<u>green card holder</u> as of 12th May, 1999.</i></b>
			</note>

now I'm going to get all that whitespace in my html output now because I
cannot use normalize ...

Anyway I can still use normalize to remove the spaces but keep the child
nodes? Without using a CDATA without disabled output escaping, which I know
works.

So my template rule currently looks like this

<xsl:template match="notes">
<p>
<xsl:call-template name="separated-list">
	<xsl:with-param name="nodes" select="note"/>
	<xsl:with-param name="separator">
		<br/><br/>
	</xsl:with-param>
</xsl:call-template>
</p>
</xsl:template>

<xsl:template name="separated-list">
	<xsl:param name="nodes"/>
	<xsl:param name="separator"/>
	<xsl:for-each select="$nodes">
		<xsl:copy-of select="."/>
		<xsl:if test="position() != last()">
			<xsl:copy-of select="$separator"/>
		</xsl:if>
	</xsl:for-each>
</xsl:template>

I bought Fung Lee's book today so I'm hoping that it'll clear up my
understanding of some issues. I like the way it's written and the
presentation. I own Mike's book too but I find it difficult to read and for
me it's very difficult to remember when things are explained to refer back
to them. I attribute this to the academic style in which it is written. If
it's any consolation Mike your book has recently travelled with me from
SEA-NRT-BKK-NRT-SEA and SEA-LHR-SEA so too have a lot of my other books ;-)

Also, MS-Word when you import the .html doesn't interpret the <br/><br/> as
a blank line does anybody know what will to the trick?

My resumes end up a .doc files but pass through as .html files as MS hasn't
got workable  .xml format for word documents yet.

The one thing I don't understand is why value-of when it converts to a
string discards nested tags.

<note>
				<b><i>Please note that I am a British and Australian citizen who is a
				<u>green card holder</u> as of 12th May, 1999.</i></b>
			</note>


I take it only considers text nodes? Where is this explained?

So the only way to stringify something is to use either text or CDATA to
make them interpreted as text nodes?

Is there anything like normalize space that will consider nested elements?

> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Jeni Tennison
> Sent: Saturday, April 21, 2001 1:41 PM
> To: Robert Nicholson
> Cc: xsl-list@lists.mulberrytech.com
> Subject: Re: [xsl] HTML in XML not getting to my html output.
>
>
> Hi Robert,
>
> > From what I can tell it's not at the point of the value of. If I
> > change that to copy-of it still doesn't print the <b> elements so
> > it's something do to with how I'm qualifying the parameter with the
> > select="note" I've tried all things to get it to pass the children
> > but it didn't work. The only thing that worked for me was using
> > disable-output-escape with a CDATA in my HTML around the block
> > making it a text node. However, I'd like to know how I can qualify
> > the child nodes in the select too so that if I use copy-of I can get
> > those nodes across because I don't like have to use a CDATA with
> > disabled output escaping.
>
> You can get the child nodes of a node by stepping down to them with
> the step:
>
>   child::node()
>
> (or just node(), since the child axis is assumed by default).
>
> So if you want to pass the child nodes of the note element in as the
> value of the parameter, then you could use:
>
>   <xsl:with-param name="nodes" select="note/node()" />
>
> Just to clarify, it's not exactly clear what output you want, but I
> think your template should look like:
>
> <xsl:template name="separated-list">
>    <xsl:param name="nodes"/>
>    <xsl:param name="separator"/>
>    <xsl:for-each select="$nodes">
>        <xsl:copy-of select="."/>
>        <xsl:if test="position() != last()">
>           <xsl:copy-of select="$separator"/>
>        </xsl:if>
>    </xsl:for-each>
> </xsl:template>
>
> I hope that helps,
>
> Jeni
>
> ---
> Jeni Tennison
> http://www.jenitennison.com/
>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]