Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: XSLT: Reduce XML to fit Schema XSLT: Reduce XML to fit SchemaTo: NULL Date: 8/14/2009 6:48:00 AM Hi all, I posted this in XSLT group before but maybe you can help me in here, too. So sorry to everyone who got this question twice because you're in both groups. Anyway, I'm pretty unexperienced using XSLT and I have a little question which I hope can be answered here: Is there a simple way to reduce an existing XML file to make it fit a XML Schema? For example if I have a XML file like this: <?xml version="1.0" encoding="UTF-8"?> <a xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://test/" xsi:schemaLocation="http://test/ result.xsd"> <b>Node B</b> <c>Node C</c> <m> <x>Node X1</x> <y>Node Y1</y> <z>Node Z1</z> <m> <x>Node X2</x> <y>Node Y2</y> <z>Node Z2</z> </m> </m> </a> and I want to create a copy of this file only with the correct nodes so that it fits a XSD like this: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://test/" targetNamespace="http://test/" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="a"> <xs:complexType> <xs:sequence> <xs:element ref="tns:b"/> <xs:element ref="tns:m"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="m"> <xs:complexType> <xs:sequence> <xs:element ref="tns:x" minOccurs="0"/> <xs:element ref="tns:y"/> <xs:element ref="tns:m" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="b"> <xs:simpleType> <xs:restriction base="xs:string"/> </xs:simpleType> </xs:element> <xs:element name="x"> <xs:simpleType> <xs:restriction base="xs:string"/> </xs:simpleType> </xs:element> <xs:element name="y"> <xs:simpleType> <xs:restriction base="xs:string"/> </xs:simpleType> </xs:element> </xs:schema> I'm sure this can be done with XSLT and I guess it surely doesn't take much effort to do this. Can anyone give me a little hint on how to solve this? Thank you! Best regards, Chris Marco | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
