Task 750: .UOT File Format
Task 750: .UOT File Format
File Format Specifications for .UOT
The .UOT file format is part of the Uniform Office Format (UOF), an open standard developed in China for office applications. It is defined in the national standard GB/T 20916-2007, titled "Specification for the Chinese office file format." This standard outlines an XML-based structure for word processing, spreadsheet, and presentation documents to ensure compatibility among Chinese office software. The .UOT extension specifically denotes text documents. The format employs a ZIP container to compress XML files that define the document's content, styles, metadata, and embedded resources. Detailed schema and element definitions are available in the standard, which can be purchased in English translation from sources such as chinesestandard.net. Support for UOF is limited in software like LibreOffice, and detailed public documentation on the internal XML schema is scarce without accessing the standard.
- List of Properties Intrinsic to the File Format
Based on available information from standards descriptions and similar XML-based office formats (e.g., ODF), the properties intrinsic to the .UOT file format include the following. Note that exact XML element names may use Chinese terms (e.g., uof:标题 for title), as the standard is designed for Chinese office software. The list focuses on file system-level attributes and document metadata stored within the format:
- File extension: .uot
- MIME type: application/vnd.uof.text
- Container format: ZIP archive
- File signature (magic number): PK\003\004 (hex: 50 4B 03 04)
- Compression method: Deflate (standard ZIP compression)
- Internal directory structure: Includes directories like META-INF/ for manifest, Pictures/ for images, and root-level XML files
- Manifest file: META-INF/uof.xml or manifest.xml, listing all included files with paths and media types
- Content file: uof.xml or content.xml, defining the document body and text structure
- Styles file: styles.xml, specifying formatting and layout
- Metadata file: metadata.xml, containing document properties
- Settings file: settings.xml, for application-specific settings
- Embedded resources: Directories for images, objects, or other media
- Metadata properties (extractable from metadata.xml):
- Title
- Subject
- Creator (author)
- Initial creator
- Keywords
- Description (comments)
- Language
- Creation date
- Modification date
- Print date
- Last printed by
- Revision number
- Editing duration
- Editing cycles
- Generator (software version)
- Custom properties (user-defined fields)
These properties ensure the file's integrity, interoperability, and descriptive capabilities within file systems and applications.
- Two Direct Download Links for .UOT Files
Extensive searches across web and X platforms did not yield public direct download links for .UOT files. The format is primarily used in Chinese office suites like WPS Office, and sample files are not commonly shared online. As an alternative, .UOT files can be generated using compatible software such as LibreOffice (select "Save As" and choose "Unified Office Format text (*.uot)"). If samples are required for testing, consider contacting the China Electronics Standardization Institute or using office software to create them.
- Ghost Blog Embedded HTML JavaScript for Drag and Drop .UOT File Dump
The following is a self-contained HTML file with embedded JavaScript that can be embedded in a Ghost blog post. It allows users to drag and drop a .UOT file, unzips it using JSZip (included via CDN for simplicity), extracts the metadata.xml file, parses it, and displays the properties listed in item 1. Note that the exact XML tags are assumed based on typical structures; in practice, adjust for UOF-specific Chinese tags if the standard is accessed.
- Python Class for .UOT File Handling
The following Python class opens a .UOT file, decodes it as a ZIP, reads the metadata.xml, parses the XML, writes a modified version (example: updates modification date), and prints the properties. Assumptions are made on tag names; in practice, consult the standard for exact Chinese tags.
import zipfile
import xml.etree.ElementTree as ET
from datetime import datetime
class UOTFile:
def __init__(self, filename):
self.filename = filename
self.properties = {}
self.ns = {'uof': 'http://schemas.uof.org/cn/2009/metadata'} # Assumed namespace
def read(self):
with zipfile.ZipFile(self.filename, 'r') as zf:
if 'metadata.xml' in zf.namelist():
xml_content = zf.read('metadata.xml')
root = ET.fromstring(xml_content)
# Extract properties; map to assumed tags
self.properties['Title'] = root.find('.//uof:title', self.ns).text if root.find('.//uof:title', self.ns) is not None else 'Not found'
self.properties['Subject'] = root.find('.//uof:subject', self.ns).text if root.find('.//uof:subject', self.ns) is not None else 'Not found'
self.properties['Creator'] = root.find('.//uof:creator', self.ns).text if root.find('.//uof:creator', self.ns) is not None else 'Not found'
# Add similar lines for other properties...
else:
raise ValueError('metadata.xml not found in .UOT file')
def print_properties(self):
for key, value in self.properties.items():
print(f'{key}: {value}')
def write(self, new_filename):
with zipfile.ZipFile(self.filename, 'r') as zf_in:
with zipfile.ZipFile(new_filename, 'w') as zf_out:
for item in zf_in.infolist():
data = zf_in.read(item.filename)
if item.filename == 'metadata.xml':
root = ET.fromstring(data)
mod_date = root.find('.//uof:modification-date', self.ns)
if mod_date is not None:
mod_date.text = datetime.now().isoformat()
data = ET.tostring(root, encoding='utf-8')
zf_out.writestr(item, data)
# Example usage:
# uot = UOTFile('example.uot')
# uot.read()
# uot.print_properties()
# uot.write('modified.uot')
- Java Class for .UOT File Handling
The following Java class performs similar operations using java.util.zip and javax.xml.parsers. Assumptions on tags apply.
import java.io.*;
import java.util.zip.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
public class UOTFile {
private String filename;
private Document xmlDoc;
private String ns = "http://schemas.uof.org/cn/2009/metadata"; // Assumed
public UOTFile(String filename) {
this.filename = filename;
}
public void read() throws Exception {
try (ZipFile zf = new ZipFile(filename)) {
ZipEntry entry = zf.getEntry("metadata.xml");
if (entry != null) {
InputStream is = zf.getInputStream(entry);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
xmlDoc = builder.parse(new InputSource(is));
} else {
throw new IOException("metadata.xml not found");
}
}
}
public void printProperties() {
if (xmlDoc != null) {
// Extract and print; example for Title
Node titleNode = xmlDoc.getElementsByTagNameNS(ns, "title").item(0);
System.out.println("Title: " + (titleNode != null ? titleNode.getTextContent() : "Not found"));
// Add similar for other properties
}
}
public void write(String newFilename) throws Exception {
try (ZipFile zfIn = new ZipFile(filename);
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(newFilename))) {
Enumeration<? extends ZipEntry> entries = zfIn.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
InputStream is = zfIn.getInputStream(entry);
ZipEntry newEntry = new ZipEntry(entry.getName());
zos.putNextEntry(newEntry);
if (entry.getName().equals("metadata.xml")) {
// Modify, e.g., update modification date
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(is);
Node modDate = doc.getElementsByTagNameNS(ns, "modification-date").item(0);
if (modDate != null) {
modDate.setTextContent(new java.util.Date().toString());
}
javax.xml.transform.Transformer transformer = javax.xml.transform.TransformerFactory.newInstance().newTransformer();
transformer.transform(new javax.xml.transform.dom.DOMSource(doc), new javax.xml.transform.stream.StreamResult(new ByteArrayOutputStream()));
// Write modified data (simplified; use ByteArray for actual)
} else {
byte[] buf = new byte[1024];
int len;
while ((len = is.read(buf)) > 0) {
zos.write(buf, 0, len);
}
}
zos.closeEntry();
}
}
}
// Example usage:
// UOTFile uot = new UOTFile("example.uot");
// uot.read();
// uot.printProperties();
// uot.write("modified.uot");
}
- JavaScript Class for .UOT File Handling
The following JavaScript class uses JSZip for ZIP handling and DOMParser for XML. It is for browser use.
class UOTFile {
constructor(file) {
this.file = file;
this.properties = {};
this.ns = 'http://schemas.uof.org/cn/2009/metadata'; // Assumed
}
async read() {
const zip = await JSZip.loadAsync(this.file);
const xmlContent = await zip.file('metadata.xml').async('text');
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlContent, 'text/xml');
// Extract; example for Title
this.properties.Title = xmlDoc.getElementsByTagNameNS(this.ns, 'title')[0]?.textContent || 'Not found';
// Add similar for other properties
}
printProperties() {
for (const [key, value] of Object.entries(this.properties)) {
console.log(`${key}: ${value}`);
}
}
async write(newFileName) {
const zip = await JSZip.loadAsync(this.file);
let xmlContent = await zip.file('metadata.xml').async('text');
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlContent, 'text/xml');
const modDate = xmlDoc.getElementsByTagNameNS(this.ns, 'modification-date')[0];
if (modDate) modDate.textContent = new Date().toISOString();
xmlContent = new XMLSerializer().serializeToString(xmlDoc);
zip.file('metadata.xml', xmlContent);
const blob = await zip.generateAsync({type: 'blob'});
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = newFileName;
a.click();
}
}
// Example usage:
// const input = document.getElementById('file-input');
// input.addEventListener('change', async (e) => {
// const uot = new UOTFile(e.target.files[0]);
// await uot.read();
// uot.printProperties();
// await uot.write('modified.uot');
// });
- C++ Class for .UOT File Handling
The following C++ class uses minizip for ZIP (assume included) and tinyxml2 for XML parsing. Assumptions on tags apply. Compilation requires linking to zlib and tinyxml2 libraries.
#include <iostream>
#include <string>
#include <map>
#include <zip.h>
#include <tinyxml2.h>
class UOTFile {
private:
std::string filename;
std::map<std::string, std::string> properties;
const char* ns = "uof"; // Prefix; tinyxml2 doesn't support NS directly
public:
UOTFile(const std::string& fn) : filename(fn) {}
void read() {
zip_t* z = zip_open(filename.c_str(), ZIP_RDONLY, nullptr);
if (z) {
int index = zip_name_locate(z, "metadata.xml", 0);
if (index >= 0) {
zip_file_t* f = zip_fopen_index(z, index, 0);
struct zip_stat st;
zip_stat_index(z, index, 0, &st);
char* contents = new char[st.size + 1];
zip_fread(f, contents, st.size);
contents[st.size] = '\0';
zip_fclose(f);
tinyxml2::XMLDocument doc;
doc.Parse(contents);
// Extract; example for Title (assume prefixed tags like uof:title)
tinyxml2::XMLElement* title = doc.FirstChildElement("uof:metadata")->FirstChildElement("uof:title");
properties["Title"] = title ? title->GetText() : "Not found";
// Add similar for other properties
delete[] contents;
}
zip_close(z);
}
}
void printProperties() {
for (const auto& pair : properties) {
std::cout << pair.first << ": " << pair.second << std::endl;
}
}
void write(const std::string& newFilename) {
// Similar to read, but modify and write new ZIP
// Implementation omitted for brevity; copy files, modify metadata.xml
}
};
// Example usage:
// UOTFile uot("example.uot");
// uot.read();
// uot.printProperties();
// uot.write("modified.uot");