xsl-list
[Top] [All Lists]

Re: [xsl] how to match elements in all depth

2008-03-25 06:11:50
Ok, may be the question is too long. Let's put it in short words.
I have this document:

<xml version="1.0">
<root>
<myelement attr1="val">
   <myelement>
   </myelement>
</myelement>
</root>

A template that process "myelement" tag would be:

<xsl:template match="myelement">
found  element <value-of select="name(.)" />
</xsl:template>

This will process only the outer element and will never reach the inner one ! is there a way I can process the nested "myelement " ?

Thank you.


Mansour wrote:
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>
--~--




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