[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: if child element does not exist stop generation

Subject: Re: if child element does not exist stop generation
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Tue, 3 May 2005 20:20:25 +1000
java if exists
> 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)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.