xsl-list
[Top] [All Lists]

RE: end.tag minimization problem continued

2005-05-17 06:18:27
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(_dot_)petterson(_at_)ericsson(_dot_)com>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
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?

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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>