RE: [xsl] Insert elment in XSD

Subject: RE: [xsl] Insert elment in XSD
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 29 Feb 2008 13:14:28 -0000
I would be inclined to change:

   <xsl:element name="element" use-attribute-sets="ns1:definition" />
   <xsl:apply-templates/> 

to
   <xsl:variable name="x" select="xs:element[@name='booktitle']"/>
   <xsl:apply-templates select="$x/preceding-sibling::node()"/>
   <xsl:element name="element" use-attribute-sets="ns1:definition" />
   <xsl:apply-templates select="$x/(.,following-sibling::node())"/> 

Michael Kay
http://www.saxonica.com

> -----Original Message-----
> From: igutierrez027@xxxxxxxxxxxxx 
> [mailto:igutierrez027@xxxxxxxxxxxxx] 
> Sent: 29 February 2008 10:36
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Insert elment in XSD
> 
> Hello everybody!
> 
> I need insert one element in an XSD with XSLT 2.0 but in one 
> position specific. This is the XSD and the stylesheet XSL:
> 
> 
> 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="author" type="xs:string"/>  
>    <xs:element name="booktitle" type="xs:string"/>
> 
> </xs:schema> 
> 
> 
> This is my XSL:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>     xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
> xmlns:ns1="http://bibtexml.sf.net/"; version="2.0"
>     xmlns:dc="http://purl.org/dc/elements/1.1/";>
>         
>     <xsl:param name="file" as="xs:string">reviewed</xsl:param>
> 
>       <xsl:attribute-set name="ns1:definition">
>         <xsl:attribute name="name">
>             <xsl:value-of select="$file"/>
>         </xsl:attribute>
>         <xsl:attribute name="type">xs:string</xsl:attribute>
>     </xsl:attribute-set>
>   
>     <xsl:template match="@* | node()">
>         <xsl:copy>
>             <xsl:apply-templates select="@* | node()"/>
>         </xsl:copy>
>     </xsl:template>
> 
>     <xsl:template match="xs:schema">
>         <xsl:copy>
>             <xsl:element name="element" 
> use-attribute-sets="ns1:definition" />
>             <xsl:apply-templates/>
>         </xsl:copy>
>     </xsl:template>
>  
> </xsl:stylesheet>
> 
> 
> This stylesheet runs well but I need introduce the element in 
> a concret 
> position under    <xs:element name="booktitle" 
> type="xs:string"/>  like 
> a child of <xs:schema...> tag.
> 
> Any way to do it?
> 
> Thank You.
> 
> Izaskun

Current Thread