Jump to content

Schema Help


EJ257
 Share

Recommended Posts

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

Link to comment
Share on other sites

Try adding:

elementFormDefault="qualified"

To xs:schema.You may get:

<ns3:

at every element, but at least all elements will be in your targetNamespace.As for your #styling part, you'll have to explicity declare that URI too, and use in the Schema where appropriate. E.g.

<xs:schema ... xmlns:tts="http://www.w3.org/2006/04/ttaf1#styling">...<xs:complexType name="styleType">	<xs:attribute name="tts:fontFamily" type="xs:string"/>	<xs:attribute name="tts:fontSize" type="xs:string"/>	<xs:attribute name="tts:color" type="xs:string"/>	<xs:attribute name="tts:id" type="xs:string"/></xs:complexType>

Link to comment
Share on other sites

As for your #styling part, you'll have to explicity declare that URI too, and use in the Schema where appropriate. E.g.
<xs:schema ... xmlns:tts="http://www.w3.org/2006/04/ttaf1#styling">...<xs:complexType name="styleType">	<xs:attribute name="tts:fontFamily" type="xs:string"/>	<xs:attribute name="tts:fontSize" type="xs:string"/>	<xs:attribute name="tts:color" type="xs:string"/>	<xs:attribute name="tts:id" type="xs:string"/></xs:complexType>

Thanks for your quick reply.I added the information you suggested, and I'm getting the following error when I try to load the schema into Excel:xml.jpgIs the "tts:" not allowed in a name field? Edited by EJ257
Link to comment
Share on other sites

Thanks for your quick reply.I added the information you suggested, and I'm getting the following error when I try to load the schema into Excel:xml.jpgIs the "tts:" not allowed in a name field?
Normally, it should be... if Excel doesn't support it, that's an Excel problem.Try to separate those attributes in a separate schema. Then, <xs:import/> it, and specify the namespace too.
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
 Share

×
×
  • Create New...