{"data":{"slug":"github-xberg-io-xberg-ai-rulez-skills-format-specific-extraction-cf536db5a555","title":"Format-Specific Extraction Workflows","summary":"Extract content, metadata, and structure from various file formats using format-specific extractors.","url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-ai-rulez-skills-format-specific-extraction-cf536db5a555","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-xberg-io-xberg-ai-rulez-skills-format-specific-extraction-cf536db5a555","markdown_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-ai-rulez-skills-format-specific-extraction-cf536db5a555.md","download_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-ai-rulez-skills-format-specific-extraction-cf536db5a555\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"The workflow requires a configured SecurityBudget to limit resource usage and prevent malicious content exhaustion.","instructions":"---\ntype: Playbook\ntitle: Format Specific Extraction\ndescription: \"Add or change format extractors: parsers, archive budgets and metadata.\"\npaths:\n  - \"crates\/xberg\/src\/extractors\/**\"\n  - \"crates\/xberg\/src\/extraction\/**\"\nx-ai-rulez:\n  kind: skill\n  id: format-specific-extraction\n  metadata:\n    priority: high\n    name: format-specific-extraction\n---\n\n# Format-Specific Extraction Workflows\n\n## Office XML (DOCX\/PPTX\/ODT)\n\n```text\nZIP archive \u2192 SecurityBudget \u2192 XML parsing \u2192 Text + tables + metadata\n```\n\n1. `let budget = SecurityBudget::from_config(config);` (`extractors\/security.rs`), plus\n   `config.security_limits\u2026max_files_in_archive` as the member cap. The Office path does\n   **not** use `ZipBombValidator` \u2014 that is the archive\/iWork\/HWPX path.\n2. Open with `zip::ZipArchive::new(cursor)` and read the parts\n   (`word\/document.xml`, `ppt\/slides\/*.xml`, `content.xml`).\n3. Parse with `quick-xml::Reader` (streaming), threading `&mut budget` through the recursive\n   walkers so a hostile document exhausts a budget instead of memory.\n4. Metadata via `crate::extraction::office_metadata` \u2014 see the helper table below. There is no\n   `extract_metadata()`.\n5. See `extractors\/docx.rs`, `extractors\/pptx.rs`, `extractors\/odt.rs`.\n\n## PDF\n\n```text\nBytes \u2192 xberg_native_pdf \u2192 Per-page text + OCR fallback \u2192 Tables \u2192 Metadata\n```\n\n1. `xberg_native_pdf::PdfDocument::from_bytes(content.to_vec())?` \u2014 the engine takes an owned\n   `Vec<u8>`, not a slice.\n2. OCR is forced by `config.force_ocr` (whole document) or `config.force_ocr_pages`\n   (`Option<Vec<u32>>`); otherwise pages with no extractable text route to OCR.\n3. `config.pages: Option<PageConfig>` controls per-page output \u2014 it does not gate tables.\n4. Feature-gated `#[cfg(feature = \"pdf\")]`; the backend is `PdfConfig.backend`\n   (`native` default, `pdfium` behind `pdf-pdfium`).\n5. See `extractors\/pdf\/mod.rs`.\n\n## Archives (ZIP\/TAR\/7z\/GZIP)\n\n```text\nZipBombValidator \u2192 per-format metadata \u2192 per-format text content\n```\n\n1. `ZipBombValidator::new(limits).validate(&mut archive)?` before any extraction.\n2. Metadata and content come from per-format helpers in `extraction\/archive\/`:\n   `extract_{zip,tar,7z,gzip}_metadata`, `extract_{zip,tar,7z,gzip}_text_content`,\n   `extract_{zip,tar,7z}_file_bytes`. There is no `build_archive_result()`.\n3. See `extractors\/archive.rs`, `extraction\/archive\/{zip,tar,sevenz,gzip}.rs`.\n\n## Structured Text (JSON\/YAML\/TOML\/XML)\n\nSingle `StructuredExtractor` covers several MIME types: parse with the format library,\npretty-print to text. See `extractors\/structured.rs`.\n\n## Email (EML\/MSG\/PST)\n\nParse headers \u2192 extract body (text\/html) \u2192 process attachments. Message-in-message nesting is\nbounded by the `SecurityBudget`'s `SecurityLimits`-derived `DepthValidator`, the same counter\nevery other format uses. See `extraction\/email\/`, `extractors\/email.rs`, `extractors\/pst.rs`.\n\n## Common Helpers\n\n| Helper | Location |\n| --- | --- |\n| `extract_core_properties()` | `extraction\/office_metadata\/core_properties.rs` |\n| `extract_custom_properties()` | `extraction\/office_metadata\/custom_properties.rs` |\n| `extract_{docx,xlsx,pptx}_app_properties()` | `extraction\/office_metadata\/app_properties.rs` |\n| `extract_odt_properties()` | `extraction\/office_metadata\/odt_properties.rs` |\n| `cells_to_markdown()` | `extraction\/markdown.rs` (`pub(crate)`) |\n| `SecurityBudget`, `SecurityLimits` | `extractors\/security.rs` |\n| `ZipBombValidator`, `DepthValidator` | `extractors\/security.rs` |\n| `StringGrowthValidator` | `extractors\/security.rs` |\n\nThe security types are `pub(crate)`: in-crate extractors can use them, out-of-crate plugin\nauthors cannot.\n\n## Adding a New Format\n\n1. Add one `FormatEntry` to the `FORMATS` registry in `core\/mime.rs`. `EXT_TO_MIME` and\n   `SUPPORTED_MIME_TYPES` are derived from it \u2014 do not hand-edit either. See\n   `mime-detection-routing` for the full procedure, including the count assertion to bump.\n2. Create an extractor implementing `InternalDocumentExtractor` (not `DocumentExtractor`).\n3. Set `supported_mime_types()` and `priority()` (default 50).\n4. Register in `extractors\/mod.rs \u2192 register_default_extractors()`.\n5. Feature-gate if optional: `#[cfg(feature = \"my-format\")]`.\n6. Apply `SecurityBudget` \/ `SecurityLimits` to any user-supplied content.\n7. Add `#[cfg_attr(alef, alef(skip))]` to the extractor struct or the binding regen aborts.\n8. Add tests with fixture files (see the `test-corpus` skill for where fixtures come from).\n","use_cases":["Extract text and metadata from a DOCX file","Parse structured data from a JSON file","Analyze a PDF document with OCR fallback"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/xberg-io\/xberg\/blob\/ffbf7971796a126fc52f6bb8fb40418772071f61\/.ai-rulez\/skills\/format-specific-extraction\/SKILL.md","source_commit":"ffbf7971796a126fc52f6bb8fb40418772071f61","license":null,"version":null,"listing_approved_at":"2026-11-16","created_at":"2026-11-15T13:32:13.000000Z","updated_at":"2026-11-16T05:16:54.000000Z","seo_title":"Format-Specific Extraction Workflows for Content Analysis","seo_description":"Efficiently extract text, tables, and metadata from DOCX, PDF, ZIP, and structured formats with format-specific workflows.","seo_keywords":["format-specific extraction","DOCX metadata extraction","PDF text extraction","structured data parsing","ZIP archive analysis"]}}