Subject: Re: if child element does not exist stop generation
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Tue, 3 May 2005 20:20:25 +1000
|
> I need to check if there is a <length>-element as child to <sequence>
otherwise I need to terminate my code generation.
When the current node is a "sequence" use:
<xsl:if test="length">
<!-- Do whatever is necessary here -->
</xsl:if>
Cheers,
Dimitre Novatchev
On 5/3/05, Mikael Petterson (KI/EAB) <mikael.petterson@xxxxxxxxxxxx> wrote:
> Hi,
>
> I have the following line in my xml:
> =========================
> .....
> <attribute name="reserved">
> <description>
> Reference to other product
> </description>
> <readOnly/>
> <dataType>
> <sequence>
> <moRef name="Object"/>
> <length>5</length>
> <nonUnique/>
> </sequence>
> </dataType>
> </attribute>
>
> I need to check if there is a <length>-element as child to <sequence>
otherwise I need to terminate my code generation.
>
> All hints are very much appreciated.
>
> Cheers,
>
> //Mikael
>
> This is my xsl:
>
> <xsl:when test="sequence">
> <xsl: if test="not(name(./*)='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>
> </xsl:when>
>
> I get the following error message:
>
> [java] [Fatal Error] interface.xsl:477: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)
> [java] at org.apache.tools.ant.Target.performTasks(Target.java:369)
> [java] at
org.apache.tools.ant.Project.executeTarget(Project.java:1214)
> [java] at
org.apache.tools.ant.Project.executeTargets(Project.java:1062)
> [java] at org.apache.tools.ant.Main.runBuild(Main.java:673)
> [java] at org.apache.tools.ant.Main.startAnt(Main.java:188)
> [java] at
org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
> [java] at
org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
|