Subject: RE: [xsl] how to match elements in all depth From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Tue, 25 Mar 2008 23:56:50 -0000 |
Since the structure of your schema document is highly recursive, it's strange that you want to process it without using recursion. Generally, the recursive-descent style of processing in XSLT - the standard push model using templates that match a node and do <xsl:apply-templates/> on its children - is ideal for this kind of work. Having said that, processing XML Schema documents in their full generality using XSLT is not easy. It's feasible if you know something about the subset of XSDL that has been used in your particular source schema. For example, matching on xs:element/xs:complexType/xs:sequence is fine so long as the schema does not use global (named) complex types or named model groups or restrictions or extensions... Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Mansour [mailto:mansour77@xxxxxxxxx] > Sent: 24 March 2008 22:35 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] how to match elements in all depth > > 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.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] how to match elements in , Andrew Welch | Thread | [xsl] Increase Doc-available timeou, Angela Williams |
Re: [xsl] Selecting unparsed text f, David Carlisle | Date | Re: [xsl] Selecting unparsed text f, Jefferson Thomas |
Month |