Re: [xsl] xsl and xml CDATA or Not question

Subject: Re: [xsl] xsl and xml CDATA or Not question
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 12 Mar 2004 17:08:37 GMT

  Thanks for your reply. I searched the faq but didn't find what I was looking
  for, but I could have not searched correctly.

Not necessarily:-) my definition of faq was a question that gets
frequently asked (most weeks, i would guess) I just assume these things
automatically end up in DaveP's pages somewehere...

  And got this
  xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; inserted into
  a lot of the code. 
  Is there a way to get rid of that. Plus, my other question is now.

Easiest way is not to put it in the source, so it wont be copied
(W3C Schema should never have defined these xsl namespaced attrbutes
which then polute every other document type)
othewise, you don't want a copy so instead of
<xsl:copy-of select="node()"/>
you want xsl:apply-templates/> together with a template something like
<xsl:template match="*">
 <xsl:element name="local-name()">
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>

here, <xsl:element name="local-name()"> will produce an element with
same name as in the source file but as it is generated, rather than
copied, it won't pick up stray namespaces.

  What do I need to do to make changes to certain tags like the img tag in the
  Content html?

XSLT has no access to the tags in your source file, only to elements
nodes in the tree, which isn't quite the same thing,

<xsl:template match="img">
[img: <xsl:value-of select="@alt|@ALT"]
</xsl:template>

  I know its something like this but im missing something cause this doesn't
  work.

Th eone you have would work (but it neednt be that complicated) if it
doesn't then presumably you are not applying templates to img elements
so that template isn't firing (ie, something is wrong somewhere else in
your stylesheet)

In particular if you are using namespaces, and your html-ish elements
are in the xhtml namespace match="img" won't work as that maches img in
no namespace.

david

-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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


Current Thread