
namespace latexSE = "https://www.latex-project.org/ns/dflt"
namespace latexSEbook = "https://www.latex-project.org/ns/book"

## PDF/UA-2

include "document-pdf-ua2.rnc"

## Default Article Namespace

### old form
H1 |= element latexSE:section       {attribute rolemaps-to {"H1"}, sechead.content}
H2 |= element latexSE:subsection    {attribute rolemaps-to {"H2"}, sechead.content}
H3 |= element latexSE:subsubsection {attribute rolemaps-to {"H3"}, sechead.content}
H4 |= element latexSE:paragraph     {attribute rolemaps-to {"H4"}, sechead.content}
H5 |= element latexSE:subparagraph  {attribute rolemaps-to {"H5"}, sechead.content}

### new form

heading1 = element latexSE:section-heading       {pdf2-attributes, attribute rolemaps-to {"H1"}, sechead.content}
heading2 = element latexSE:subsection-heading    {pdf2-attributes, attribute rolemaps-to {"H2"}, sechead.content}
heading3 = element latexSE:subsubsection-heading {pdf2-attributes, attribute rolemaps-to {"H3"}, sechead.content}
heading4 = element latexSE:paragraph-heading     {pdf2-attributes, attribute rolemaps-to {"H4"}, sechead.content}
heading5 = element latexSE:subparagraph-heading  {pdf2-attributes, attribute rolemaps-to {"H5"}, sechead.content}
section = element latexSE:section            {pdf2-attributes,attribute rolemaps-to {"Sect"}, heading1,(subsection|Sect.content)*}
subsection = element latexSE:subsection      {pdf2-attributes,attribute rolemaps-to {"Sect"}, heading2,(subsubsection|Sect.content)*}
subsubsection = element latexSE:subsubection {pdf2-attributes,attribute rolemaps-to {"Sect"}, heading3,(paragraph|Sect.content)*}
paragraph = element latexSE:paragraph        {pdf2-attributes,attribute rolemaps-to {"Sect"}, heading4,(subparagraph|Sect.content)*}
subparagraph = element latexSE:subparagraph  {pdf2-attributes,attribute rolemaps-to {"Sect"}, heading5,(Sect.content)*}

Sect |= section

## LaTeX Book structure Namespace

### old form
H1 |= element latexSEbook:chapter   {attribute rolemaps-to {"H1"}, sechead.content}
H2 |= element latexSE:section       {attribute rolemaps-to {"H2"}, sechead.content}
H3 |= element latexSE:subsection    {attribute rolemaps-to {"H3"}, sechead.content}
H4 |= element latexSE:subsubsection {attribute rolemaps-to {"H4"}, sechead.content}
H5 |= element latexSE:paragraph     {attribute rolemaps-to {"H5"}, sechead.content}
H6 |= element latexSE:subparagraph  {attribute rolemaps-to {"H6"}, sechead.content}

### new form

bookheading1 = element latexSEbook:chapter-heading       {pdf2-attributes, attribute rolemaps-to {"H1"}, sechead.content}
bookheading2 = element latexSEbook:section-heading       {pdf2-attributes, attribute rolemaps-to {"H2"}, sechead.content}
bookheading3 = element latexSEbook:subsection-heading    {pdf2-attributes, attribute rolemaps-to {"H3"}, sechead.content}
bookheading4 = element latexSEbook:subsubsection-heading {pdf2-attributes, attribute rolemaps-to {"H4"}, sechead.content}
bookheading5 = element latexSEbook:paragraph-heading     {pdf2-attributes, attribute rolemaps-to {"H5"}, sechead.content}
bookheading6 = element latexSEbook:subparagraph-heading  {pdf2-attributes, attribute rolemaps-to {"H6"}, sechead.content}
bookchapter = element latexSEbook:chapter            {pdf2-attributes,attribute rolemaps-to {"Sect"}, bookheading1,(booksection|Sect.content)*}
booksection = element latexSE:section            {pdf2-attributes,attribute rolemaps-to {"Sect"}, bookheading2,(booksubsection|Sect.content)*}
booksubsection = element latexSE:subsection      {pdf2-attributes,attribute rolemaps-to {"Sect"}, bookheading3,(booksubsubsection|Sect.content)*}
booksubsubsection = element latexSE:subsubection {pdf2-attributes,attribute rolemaps-to {"Sect"}, bookheading4,(bookparagraph|Sect.content)*}
bookparagraph = element latexSE:paragraph        {pdf2-attributes,attribute rolemaps-to {"Sect"}, bookheading5,(booksubparagraph|Sect.content)*}
booksubparagraph = element latexSE:subparagraph  {pdf2-attributes,attribute rolemaps-to {"Sect"}, bookheading6,(Sect.content)*}

Sect |= bookchapter

Title |= element latexSE:part {attribute rolemaps-to {"Title"}, sechead.content}

heading-number = element (latexSE:heading-number | latexSE:section-number) {
  attribute rolemaps-to {"Lbl"|"Span"},			
  pdf2-attributes,
  (text|NonStruct|Private|Note|Code|Sub|Em|Strong|Span|Quote|Link|Reference|Annot|Form|Ruby|Warichu|FENote|BibEntry|Figure|Formula|Artifact|
mathse)*
}

heading-fragment = element latexSE:heading-fragment {
  attribute rolemaps-to {"Span"},
pdf2-attributes,
(text|NonStruct|Private|Note|Code|Sub|Lbl|Em|Strong|Span|Quote|Link|Reference|Annot|Form|Ruby|Warichu|FENote|BibEntry|Figure|Formula|Artifact)*
}

heading-parbox = element (latexSE:heading-parbox|latexSE:heading-minipage) {
  attribute rolemaps-to {"Span"},
pdf2-attributes,
(text|NonStruct|Private|Note|Code|Sub|Lbl|Em|Strong|Span|Quote|Link|Reference|Annot|Form|Ruby|Warichu|FENote|BibEntry|Figure|Formula|Artifact)*
}

Lbl |= heading-number
Span |= heading-fragment|heading-parbox

# LaTeX NS

document.1 &= figures?
           & tables?

figures = element latexSE:figures {
  attribute rolemaps-to {"Sect"},
  attribute id {text}?,
  showtags-attributes,
  float*
 }

tables = element latexSE:tables {
  attribute rolemaps-to {"Sect"},
  attribute id {text}?,
  showtags-attributes,
  float*
 }

float = element latexSE:float {
  attribute rolemaps-to {"Aside"|"Note"},
  attribute id {text}?,
  showtags-attributes,
  (Caption|Part|Div|Figure|\text)*
 }



theorem-like = element latexSE:theorem-like {
  attribute rolemaps-to {"Sect"},
  attribute id {text}?,
  showtags-attributes,
  Caption?,
  Lbl?,
  (Part)*
}
Sect |= theorem-like


text-unit = element (latexSE:text-unit | latexSE:semantic-para) {
  attribute rolemaps-to {"Part"},
  pdf2-attributes,
   (title|Title)?,Caption?,(H4|H5|Div|Sect|P|Aside|Figure|Table|Formula|quote|quotation|\text|itemize|description|enumerate|verbatim|\list|Part|FENote)*}
Part |= text-unit

verbatim = element latexSE:verbatim {
  attribute rolemaps-to {"P"|"Code"},
  pdf2-attributes,
  codeline*
}
P |= verbatim

codeline = element latexSE:codeline {
  attribute rolemaps-to {"Sub"|"Span"},
  pdf2-attributes,
  (text|Em|Formula|Lbl)*
}




\list = element latexSE:list {
 attribute rolemaps-to {"L"},
  pdf2-attributes,
  list-attributes,
  LI*
}
L |= \list

itemize = element latexSE:itemize {
  attribute rolemaps-to {"L"},
  pdf2-attributes,
  list-attributes,
  LI*
}
L |= itemize

enumerate = element latexSE:enumerate {
  attribute rolemaps-to {"L"},
  pdf2-attributes,
  list-attributes,
  LI*
}
L |= enumerate

quote = element latexSE:quote {
 attribute rolemaps-to {"BlockQuote"},
 pdf2-attributes,
 (Part)*
}

quotation = element latexSE:quotation {
 attribute rolemaps-to {"BlockQuote"},
 pdf2-attributes,
 (Part|Art|Div|Sect|TOC|BlockQuote|NonStruct|Private|P|Note|Code|Hn|Title|Lbl|Link|Reference|Annot|Form|FENote|Index|L|Table|Figure|Formula|Artifact)*
}

description= element latexSE:description {
 attribute rolemaps-to {"L"},
 pdf2-attributes,
 list-attributes,
 LI*
}

item = element latexSE:item {
  pdf2-attributes,
  attribute rolemaps-to {"LI"},
  (itemlabel?,itembody?)
}

LI |= item

itemlabel = element latexSE:itemlabel {
  pdf2-attributes,
  attribute rolemaps-to {"Lbl"},
  (text|text-unit|Formula|Em|Strong|Span|Link|\text)*
}

itembody = element latexSE:itembody {
  pdf2-attributes,
  attribute rolemaps-to {"LBody"},
  (H?&Caption?&
(text|Part|Art|Div|Sect|Aside|BlockQuote|NonStruct|Private|P|Note|Code|Hn|Sub|Em|Strong|Span|Quote|Link|Reference|Annot|Form|Ruby|Warichu|FENote|Index|L|BibEntry|Table|Figure|Formula|Artifact)*)
 }


LBody |= itembody


title = element latexSE:title {
 attribute rolemaps-to {"Title"},
 pdf2-attributes,
 (Span|\text)*
 }


\text = element (latexSE:text | latexSE:text-block) {
 attribute rolemaps-to {"P"},
 pdf2-attributes,
 (text|Figure|Span|Link|Lbl|Reference|Em|Strong|FENote|Formula|Ruby|Form|Code|Annot)*
}
P |= \text

text-fragment = element latexSE:text-fragment {
attribute rolemaps-to {"Span"},
pdf2-attributes,
(text|NonStruct|Private|Note|Code|Sub|Lbl|Em|Strong|Span|Quote|Link|Reference|Annot|Form|Ruby|Warichu|FENote|BibEntry|Figure|Formula|Artifact)*
}

Span |= text-fragment

Lbl |= element latexSE:footnotemark {
 attribute rolemaps-to {"Lbl"},
 pdf2-attributes,
(text|Link|Span)*
}

FENote |= element latexSE:footnote {
  attribute rolemaps-to {"FENote"|"Note"},
  pdf2-attributes,
  footnotelabel,(Part|\text)*
}

footnotelabel = element latexSE:footnotelabel {
 attribute rolemaps-to {"Lbl"},
 pdf2-attributes,
 (text|Span|NonStruct)*
}

text-minipage =  element (latexSE:text-minipage|latexSE:text-parbox) {
  attribute rolemaps-to {"Div"},
  pdf2-attributes,
(Document|DocumentFragment|Part|Art|Div|Sect|TOC|TOCI|Aside|BlockQuote|NonStruct|Private|P|Note|Code|Hn|H|Title|Sub|Lbl|Em|Strong|Span|Quote|Link|Reference|Annot|Form|Ruby|RB|RT|RP|Warichu|WT|WP|FENote|Index|L|LI|LBody|BibEntry|Table|TR|TH|TD|THead|TBody|TFoot|Caption|Figure|Formula|Artifact)*
}

Div |= text-minipage
