PDA

View Full Version : Schema Help


EJ257
07-20-2009, 05:04 PM
I currently use a Schema to convert an Excel spreadsheet into XML format, to provide captions in timed text format for flash videos hosted online.

The schema is currently coded as follows:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/2006/04/ttaf1" xmlns="http://www.w3.org/2006/04/ttaf1">

<xs:complexType name="ttType">
<xs:sequence>
<xs:element name="head" type="headType" minOccurs="0" maxOccurs="1"/>
<xs:element name="body" type="bodyType" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="headType">
<xs:sequence>
<xs:element name="styling" type="stylingType" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="stylingType">
<xs:sequence>
<xs:element name="style" type="styleType" minOccurs="0" maxOccurs="3"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="styleType">
<xs:attribute name="fontFamily" type="xs:string"/>
<xs:attribute name="fontSize" type="xs:string"/>
<xs:attribute name="color" type="xs:string"/>
<xs:attribute name="id" type="xs:string"/>
</xs:complexType>

<xs:complexType name="bodyType">
<xs:sequence>
<xs:element name="div" type="divType" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="divType">
<xs:sequence>
<xs:element name="p" type="subtitleType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="style" use="required"/>
</xs:complexType>

<xs:complexType name="subtitleType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="begin" use="required"/>
<xs:attribute name="end" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:element name="tt" type="ttType"/>

</xs:schema>


When we run our Excel spreadsheet with this Schema, we get the following output:

<?xml version='1.0' encoding='UTF-8'?>
<ns3:tt xmlns:ns3="http://www.w3.org/2006/04/ttaf1">
<head>
<styling>
<style fontFamily="Arial,Helvetica,sans-serif" fontSize="20" color="#ffffff" id="1"/>
</styling>
</head>
<body>
<div style="style">
<p begin="00:00:01.00" end="00:00:02.00">Time code must be in hh:mm:ss.00 format. Delete this row.</p>
</div>
</body>
</ns3:tt>


The end format needs to be as follows:

<?xml version="1.0" encoding="UTF-8"?>
<tt xml:lang="en" xmlns="http://www.w3.org/2006/04/ttaf1" xmlns:tts="http://www.w3.org/2006/04/ttaf1#styling">
<head>
<styling>
<style tts:fontFamily="Arial,Helvetica,sans-serif" tts:fontSize="20" tts:color="#ffffff" id="1"/>
</styling>
</head>
<body>
<div style="style">
<p begin="00:00:01.00" end="00:00:02.00">Time code must be in hh:mm:ss.00 format. Delete this row.</p>
</div>
</body>
</tt>


I'm having difficulty getting it fine tuned - I end up manually making a few corrections. I have to remove the "ns3" references throughout the entire output. Also, I have to add "tts" to each of the attributes in the <style> tag. Lastly, in the <tt> tag, how would I code it to include the "xmlns:tts" attribute and value, and also include the "xml-lang" attribute?

Any pointers/suggestions are welcome and greatly appreciated.

Thanks,
Matthew