Jump to content

Using XSLT to extract nested complextypes into global types


SpaceCowboy850

Recommended Posts

I have a XSD that looks something like this:

 

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

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.02">

<xs:include schemaLocation="Basic_Types.xsd"/>

<xs:element name="MyElement">

<xs:complexType mixed="true">

<xs:sequence>

<xs:element name="data">

<xs:complexType>

<xs:sequence>

<xs:element name="timeStamp" type="specialtime"/>

<xs:element name="DeviceClass">

<xs:complexType>

<xs:sequence>

<xs:element name="MaxAmount" type="Amount"/>

<xs:element name="MaxVolume" type="Volume"/>

</xs:sequence>

<xs:attribute name="Type" type="Type" use="required" fixed="FP"/>

<xs:attribute name="DeviceID" type="DeviceID" use="required"/>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:sequence>

<xs:attribute name="ApplicationSender" type="ApplicationSender" use="required"/>

<xs:attribute name="WorkstationID" type="WorkstationID" use="required"/>

</xs:complexType>

</xs:element>

</xs:schema>

 

I want to change it to look something like this:

 

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

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.02">

<xs:include schemaLocation="Basic_Types.xsd"/>

 

<xs:complexType name="DeviceClass">

<xs:sequence>

<xs:element name="MaxAmount" type="Amount"/>

<xs:element name="MaxVolume" type="Volume"/>

</xs:sequence>

<xs:attribute name="Type" type="Type" use="required" fixed="FP"/>

<xs:attribute name="DeviceID" type="DeviceID" use="required"/>

</xs:complexType>

 

<xs:complexType name="data">

<xs:sequence>

<xs:element name="timeStamp" type="specialtime"/>

<xs:element name="DeviceClass" type ="DeviceClass"/>

</xs:sequence>

</xs:complexType>

 

<xs:complexType mixed ="true" name ="MyElement">

<xs:sequence>

<xs:element name="data" type ="data">

</xs:element>

</xs:sequence>

<xs:attribute name="ApplicationSender" type="ApplicationSender" use="required"/>

<xs:attribute name="WorkstationID" type="WorkstationID

Link to comment
Share on other sites

I'm guessing you can't just replace the one file.... What of xQuery? It's simple to learn and can do just about everything xslt 1.0 can and that was xQuery version 1.0. It being now version 3.0. It should be relatively easy.

Link to comment
Share on other sites

Yeah, if it was just 1 file, it wouldn't be a big deal. As it is it is over 100 files, that are all different. I hadn't heard of XQuery, I'll take a look at that.

Also check out xqib too. It's an alternative to JavaScript for handling the dom on server side scripting. Edited by L8V2L
Link to comment
Share on other sites

If I have been of help to you, do you think you could return the kindness, and seeing to answering any of my question in the xslt thread?

Edited by L8V2L
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...