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

Re: Insert elment in XSD

Subject: Re: Insert elment in XSD
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Thu, 28 Feb 2008 13:24:47 +0100
Re:  Insert elment in XSD
igutierrez027@xxxxxxxxxxxxx wrote:
Hello everybody!

I have one XSD and I need insert into it one elment along one stylesheet. I am using XSLT 2.0 with Oxygen.

This is my XSD:

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
targetNamespace="http://bibtexml.sf.net/" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:ns1="http://bibtexml.sf.net/" version="2.0">


<xs:import namespace="http://purl.org/dc/elements/1.1/" schemaLocation="dc.xsd"/>

    <xs:element name="article">
    <xs:complexType>
      <xs:all>

<xs:element ref="ns1:author" minOccurs="1" maxOccurs="1"/>
<xs:element ref="ns1:title" minOccurs="1" maxOccurs="1"/>
</xs:all>
</xs:complexType>
</xs:element>



The element that I need insert is


<xs:element ref="ns1:reviewed" minOccurs="0" maxOccurs="1"/>

and I need to insert it between de tag <xs:all> . The result was:

 <xs:element name="article">
    <xs:complexType>
      <xs:all>

<xs:element ref="ns1:reviewed" minOccurs="0" maxOccurs="1"/>

<xs:element ref="ns1:author" minOccurs="1" maxOccurs="1"/>
<xs:element ref="ns1:title" minOccurs="1" maxOccurs="1"/>
</xs:all>
</xs:complexType>
</xs:element>


I know how to create the element, but I need the template's instructions to instert it into the XSD using the Stylesheet.


  <xsl:stylesheet
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmns:xs="http://www.w3.org/2001/XMLSchema"
     version="2.0">

     <xsl:template match="@* | node()">
       <xsl:copy>
         <xsl:apply-templates select="@* | node()"/>
       </xsl:copy>
     </xsl:template>

<xsl:template match="xs:element[@name = 'article']/xs:complexType/xs:all">
<xsl:copy>
<xs:element ref="ns1:reviewed" minOccurs="0" maxOccurs="1"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>




--

	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.