xsl-list
[Top] [All Lists]

RE: [xsl] Insert elment in XSD

2008-02-29 06:15:11
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[(_at_)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(_at_)ikasle(_dot_)ehu(_dot_)es 
[mailto:igutierrez027(_at_)ikasle(_dot_)ehu(_dot_)es] 
Sent: 29 February 2008 10:36
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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


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

<Prev in Thread] Current Thread [Next in Thread>