Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSL Transformation output -- no tags -- Help!

Reply
Thread Tools

XSL Transformation output -- no tags -- Help!

 
 
Mike Conmackie
Guest
Posts: n/a
 
      04-28-2004
Hi Folks,

I've probably omitted something very basic but I have no idea what it might
be. The results of my transformation _should_ be an xml file but all I get
is the xml declaration immediately followed by the input node text values in
one long string -- no xml tags (barring the xml declaration, of course)
appear in the output file. Anyone who wants to see either the input xml
file or the xsl file, please let me know and I will e-mail them to you.
Thanks.

Regards,

Mike Conmackie
http://www.velocityreviews.com/forums/(E-Mail Removed)


 
Reply With Quote
 
 
 
 
dan
Guest
Posts: n/a
 
      04-28-2004
"Mike Conmackie" <(E-Mail Removed)> wrote in message news:<408ff79d$1@10.10.0.241>...
<snip>
> The results of my transformation _should_ be an xml file but all I get
> is the xml declaration immediately followed by the input node text values in
> one long string

<snip>


I would guess you are using <xsl:value-of> when what it sounds like
you need is <xsl:copy-of>
 
Reply With Quote
 
 
 
 
Mike Conmackie
Guest
Posts: n/a
 
      04-28-2004
Dan,

The purpose of the transformation is to translate one tag set into another
(with slightly different output structure). Therefore, I don't think that
<xsl:copy-of> is what I want. Would you like to look at the input document
and the stylesheet? I can also show you a sample of the expected output.

Mike

"dan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> "Mike Conmackie" <(E-Mail Removed)> wrote in message

news:<408ff79d$1@10.10.0.241>...
> <snip>
> > The results of my transformation _should_ be an xml file but all I get
> > is the xml declaration immediately followed by the input node text

values in
> > one long string

> <snip>
>
>
> I would guess you are using <xsl:value-of> when what it sounds like
> you need is <xsl:copy-of>



 
Reply With Quote
 
Ben Edgington
Guest
Posts: n/a
 
      04-29-2004
Hi again,

"Mike Conmackie" <(E-Mail Removed)> writes:
> I've probably omitted something very basic but I have no idea what it might
> be. The results of my transformation _should_ be an xml file but all I get
> is the xml declaration immediately followed by the input node text values in
> one long string -- no xml tags (barring the xml declaration, of course)
> appear in the output file. Anyone who wants to see either the input xml
> file or the xsl file, please let me know and I will e-mail them to you.


This is what happens when no template in your XSL transformation
matches anything in the input XML - the built-in template rules
take over, which basically just copy the node contents.
See http://www.w3.org/TR/xslt#built-in-rule

Example:

This XML:
<a>
<b>Some stuff</b>
<c>Some other stuff</c>
</a>


With this XSLT:
<xsl:stylesheet
version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform"
>


<!-- Main template matches nothing in the input -->
<xsl:template match="/x">
<xsl:text>Hello, world!</xsl:text>
</xsl:template>

</xsl:stylesheet>


Gives this output:
<?xml version="1.0" encoding="UTF-8"?>
Some stuff
Some other stuff


Ie. just a copy of the node contents. Note that we *don't* see
"Hello, world!" which shows that the main template was did not match
anything.

This might be your problem. If you stick in a recursive copy it will
over-ride the built-in rules and match anything not already matched by
other templates. Therefore nodes you don't explicitly process are
just copied to the output (the identity transformation)

This is the version given in the W3C Rec:
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>


However, I prefer this two-template one as I generally don't want to
copy namespaces to my output:
<xsl:template match="node()">
<xsl:element name="{name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>

<xsl:template match="@*|text()|comment()|processing-instruction()">
<xsl:copy/>
</xsl:template>


Ben

--
Ben Edgington
Mail to the address above is discarded.
Mail to ben at that address might be read.
http://www.edginet.org/
 
Reply With Quote
 
Mike Conmackie
Guest
Posts: n/a
 
      04-29-2004
Hello All,

Ben's statement regarding the non-matching status of any template in the
stylesheet was the real issue. I removed the namespace prefix from the
input document and the styelsheet and life became much better. As usual,
thanks to all who offered assistance.

Mike


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use output of XSL transformation as new XSL stylesheet barney.b@iname.com XML 0 01-16-2006 02:29 PM
xsl - ignore XSL:FO tags, just output them paul.rusu@gmail.com XML 0 12-21-2005 03:49 PM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
no tags in my xml-to-xml transformation, help.... yannicklaclau XML 2 02-28-2005 03:44 PM
Am I the only one who questions JSTL, Struts Tags, XSL Tags? Greg Smith Java 35 10-24-2004 07:46 AM



Advertisments