xsl-list
[Top] [All Lists]

[xsl] how to match elements in all depth

2008-03-24 15:38:57
For some reason, I find xslt and xpath techniques are easy to forget. I believe I have done this before but couldn't remember exactly how. Ok, I have an xml schema and trying to convert it to DDL (data definition language) as SQL text. For example, I picked this schema doc from the net http://www.xml.com/lpt/a/691:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
   <xs:element name="book">
       <xs:complexType>
           <xs:sequence>
               <xs:element name="title" type="xs:string" />
               <xs:element name="author" type="xs:string" />
               <xs:element name="character" minOccurs="0"
                   maxOccurs="unbounded">
                   <xs:complexType>
                       <xs:sequence>
                           <xs:element name="name" type="xs:string" />
                           <xs:element name="friend-of"
type="xs:string" minOccurs="0" maxOccurs="unbounded" />
                           <xs:element name="since" type="xs:date" />
                           <xs:element name="qualification"
                               type="xs:string" />
                       </xs:sequence>
                   </xs:complexType>
               </xs:element>
           </xs:sequence>
           <xs:attribute name="isbn" type="xs:string" />
       </xs:complexType>
   </xs:element>
</xs:schema>

And All I am trying to do for now, is to create two tables, like this:
=========================================
CREATE TABLE book
               ( )

CREATE TABLE character
               ( )
=========================================

I have this template:
<xsl:template match="xs:element/xs:complexType/xs:sequence">
       CREATE TABLE
       <xsl:value-of select="../../@name" />
       ( )
       <xsl:apply-templates  />
   </xsl:template>
It's doing what I want, but it's using recursive calls to apply to inner complex elements. How can I do this without recursion? In other words how to match elements in all depth?

Thank you.


--~------------------------------------------------------------------
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>