[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] end.tag minimization problem continued


Subject: RE: [xsl] end.tag minimization problem continued
From: "Aron Bock" <aronbock@xxxxxxxxxxx>
Date: Tue, 17 May 2005 13:18:27 +0000

Mikael,

With this XML:

<dataType>
   <sequence>
       <moRef name="ManagedObject"/>
       <length>5</length>
   </sequence>
</dataType>

And this XSL (on xalan):

<?xml version="1.0" encoding="iso8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>


   <xsl:template match="sequence">
       <!-- Check if <sequence>-element has no <length> attribute.-->
       foo
       <xsl:if test="not(length)">
           <xsl:message terminate="yes">
           <!-- class name and attribute error message -->
            Attribute:<xsl:value-of select="../@name"/>
            Class:    <xsl:value-of select="../../@name"/>
            Error:    sequence missing child element, length.
          </xsl:message>
       </xsl:if>
       bar
   </xsl:template>

</xsl:stylesheet>

I get:

       foo
       bar

which is what was expected. Same with empty-element <length/>. When I remove the <length> element I get a termination message, again as expected.

Regards,

--A


From: "Mikael Petterson (KI/EAB)" <mikael.petterson@xxxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: [xsl] end.tag minimization problem continued
Date: Tue, 17 May 2005 07:35:07 +0200

Hi,

We are transforming and xml into java code using xsl/xslt in java.
Ny xsl look like this;

......
<!-- Start: Sequence -->
     <xsl:when test="sequence">
     <!-- Check if <sequence>-element has no <length> attribute.-->
     <xsl:if test="not(length)">
      <xsl:message terminate="yes">
        <!-- class name and attribute error message -->
         Attribute:<xsl:value-of select="../@name"/>
	     Class:    <xsl:value-of select="../../@name"/>
         Error:    sequence missing child element, length.
       </xsl:message>
     </xsl:if>
........

When I execute my transformation it fails ( see error below).
The following xml is ok:

<dataType>
                 <sequence>
                     <long>
                        <range>
                            <min>-500</min> <max>500</max>
                        </range>
                     </long>
                     <length>12</length>
                 </sequence>
 </dataType>

But when this xml is tranformed ( below) it fails:

<dataType>
                 <sequence>
                    <moRef name="ManagedObject"/>
                     <length>5</length>
                 </sequence>
</dataType>

I interpret it as when I have a single <element/> I get the error but when I have <element></element> it is a ok.
Do I have to make any settings to the xml transformation?

_________________________________________________________________
Dont just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/



Current Thread
Keywords