RE: [xsl] if child element does not exist stop generation

Subject: RE: [xsl] if child element does not exist stop generation
From: "Mikael Petterson \(KI/EAB\)" <mikael.petterson@xxxxxxxxxxxx>
Date: Tue, 3 May 2005 15:58:39 +0200
Hi,

I am still getting the same error ( see below).

If I remove the following lines (see below) all is ok.

Any more hints ? I am really stuck!

Cheers,

//Mikael


lines removed
=============
  <xsl:value-of select="."/> <!-- This is to print the current node -->
     <xsl: if test="length">
      <xsl:message terminate="yes">
        <!-- class name and attribute error message -->
         Attribute:<xsl:value-of select="../@name"/>
         Error:sequence missing <length> child!
       </xsl:message>
      </xsl:if>

error log
=========
Buildfile: /vobs/rbs/sw/rbssw_tools/boam_tools/xml2j/build/build.xml

init:
     [echo] output dir is /vobs/rbs/sw/rbssw_tools/boam_tools/xml2j/output
     [echo] template file is interface.xsl!
     [echo] package is se/ericsson/wcdma/rbs/boam/mao/iface/mo

compile:
     [echo] Compiling with 1.4!

execute:
     [java] [Fatal Error] interface.xsl:478:11: Element or attribute do not
match QName production: QName::=(NCName':')?NCName.

     [java] ** Transformer Factory error
     [java]    javax.xml.transform.TransformerConfigurationException:
javax.xml.transform.TransformerException: org.xml.sax.SAXParseException:
Element or attribute do not match QName production:
QName::=(NCName':')?NCName.
     [java] javax.xml.transform.TransformerConfigurationException:
javax.xml.transform.TransformerException: org.xml.sax.SAXParseException:
Element or attribute do not match QName production:
QName::=(NCName':')?NCName.
     [java]     at
org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFac
toryImpl.java:807)
     [java]     at
org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerF
actoryImpl.java:666)
     [java]     at se.ericsson.xml2j.common.Main.main(Main.java:82)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
     [java]     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.
java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:324)
     [java]     at
org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:193)
     [java]     at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:130)
     [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:705)
     [java]     at
org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:177)
     [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:83)
     [java]     at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
     [java]     at org.apache.tools.ant.Task.perform(Task.java:364)
     [java]     at org.apache.tools.ant.Target.execute(Target.java:341)

-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: den 3 maj 2005 12:21
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] if child element does not exist stop generation


> Hi,
>          You can do this using:
>
><xsl:if test="*[self::length]"> or

That is more easily written as

<xsl:if test="length">

>  or
>
> <xsl:if test="*[name() = 'length']">

It's best not to use name() function as it makes the stylesheet hard to
make namespace-aware. And formally the values returned by name() are
always processor dependent as the processor may (although probably does
not) assign arbitarary prefixes to namespace while parsing the input.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. 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
________________________________________________________________________

Current Thread