Re: RE: [xsl] Simple XML transformation advice needed

Subject: Re: RE: [xsl] Simple XML transformation advice needed
From: Peter Dalmaris <Peter.P.Dalmaris@xxxxxxxxxx>
Date: Wed, 28 Jan 2004 17:10:13 +1100
Hi Kenny,

yes, it works fine on the command line when using the Saxon parser. When I apply the stylesheet in my Java application using the Xerces parser (org.apache.xerces.jaxp) it gives me this error:

file:///E:/docos/transform.xsl; Line #8; Column #2; Cannot add attribute TextAlignment after child nodes or before an element is produced.  Attribute will be ignored.

I am pretty sure it is the Java parser that is causing the problem. So the question is, which parser implements the standard XSLT specification? If Xerces is a good standard parser, how can I modify my XSLT file to run with it?

Thanks again,

Peter

-----------------------------------
sunlight (definition): that which makes a computer monitor difficult to see

----- Original Message -----
From: Kenny Akridge <kakridge@xxxxxxxxxxxxx>
Date: Wednesday, January 28, 2004 4:00 pm
Subject: RE: [xsl] Simple XML transformation advice needed

> I'm not sure what the problem is.  I ran your code and got the output
> you are looking for:
> 
> <ap:Text TextAlignment="urn:mindjet:Left" Dirty="0000000000000001">
> 	<PlainText>Motivation, research problem and hypothesis
> 9</PlainText>
> 	<ap:Font Color="ff000000"/>
> 
> 
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Peter
> Dalmaris
> Sent: Tuesday, January 27, 2004 10:53 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Simple XML transformation advice needed
> 
> Hello all,
> 
> I am a novice with XSLT and would appreciate any help in relation 
> to a
> little problem I am having.
> 
> I have written a simple transformation XSL program that trasforms 
> an XML
> document into a slightly different document, but I am having some
> trouble getting it right.
> 
> More details and the code is below.
> 
> Thank you,
> 
> Peter
> -----------------------------------------------
> PROBLEM: 
> 
> What I am trying to get the template to do is to take something like
> this as input:
> 
> <ap:Text TextAlignment="urn:mindjet:Left" Dirty="0000000000000001"
> PlainText="Motivation, research problem and hypothesis 9">
> <ap:Font Color="ff000000"/>
> 
> 
> And produce this as output:
> 
> <ap:Text TextAlignment="urn:mindjet:Left" Dirty="0000000000000001">
> <PlainText>Motivation, research problem and hypothesis 9</PlainText>
> <ap:Font Color="ff000000"/>
> 
> 
> Instead, it is producing this:
> 
> <ap:Text Dirty="0000000000000001">
> <PlainText>Motivation, research problem and hypothesis 9</PlainText>
> <ap:Font Color="ff000000"/>
> 
> 
> In other words, I just want to take the PlainText attribute and 
> create a
> new element with it, not affecting any of the other attributes.
> 
> Here is the code:
> 
> ---------------------
> <!-- AttrToElement.xsl: Turn all attributes into subelements -->
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003";
> version="1.0"
> >
> <!-- Import the identity transformation. -->
> 
> <xsl:strip-space elements="*"/>
> 
> <xsl:output indent="yes"/>
> 
> <!-- Match any Attribute and turn it into an element -->
> 
> <xsl:template match="ap:Text/@PlainText">
> <xsl:element name="{name(.)}"><xsl:value-of select="."/></xsl:element>
> </xsl:template>
> 
> 
> <xsl:template match="//cor:Base64">
>        <xsl:element name="{name(.)}">
> 
>                <xsl:attribute name="xsi:nil"><xsl:value-of
> select="@xsi:nil" /></xsl:attribute>
> 
>                <xsl:attribute name="content"><xsl:value-of select="."
> /></xsl:attribute>
> 
> </xsl:element>
> 
> </xsl:template>
> 
> <xsl:template match="node()|@*">
> <!-- Copy the current node -->
> 
> <xsl:copy>
> <!-- Including any attributes it has and any child nodes -->
> <xsl:apply-templates select="@*|node()"/>
> </xsl:copy>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> -------------------------------
> 
> 
> 
> UTS CRICOS Provider Code:  00099F
> 
> DISCLAIMER
> ========================================================================
> This email message and any accompanying attachments may contain
> confidential information.  If you are not the intended recipient, 
> do not
> read, use, disseminate, distribute or copy this message or 
> attachments.If you have received this message in error, please 
> notify the sender
> immediately and delete this message. Any views expressed in this 
> messageare those of the individual sender, except where the sender 
> expressly,and with authority, states them to be the views the 
> University of
> Technology Sydney. Before opening any attachments, please check 
> them for
> viruses and defects.
> ========================================================================
> 
> 
> 
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 



UTS CRICOS Provider Code:  00099F

DISCLAIMER
========================================================================
This email message and any accompanying attachments may contain
confidential information.  If you are not the intended recipient, do not
read, use, disseminate, distribute or copy this message or attachments.
If you have received this message in error, please notify the sender
immediately and delete this message. Any views expressed in this message
are those of the individual sender, except where the sender expressly,
and with authority, states them to be the views the University of
Technology Sydney. Before opening any attachments, please check them for
viruses and defects.
========================================================================


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


Current Thread