static Element elementWithClasses( final String name, final OptionType<String> type, final String[] classes) { final StringBuilder cs = new StringBuilder(); for (int index = 0; index < classes.length; ++index) { cs.append(SXHTML.cssName(classes[index])); if ((index + 1) < classes.length) { cs.append(" "); } } type.map( new FunctionType<String, Unit>() { @Override public Unit call( final String x) { cs.append(" "); cs.append(x); return Unit.unit(); } }); final Element e = new Element(name, SXHTML.XHTML_URI.toString()); e.addAttribute(new Attribute("class", null, cs.toString())); return e; }
/** * Serialize the given element to XML. * * @param s * The element * @return An XML element */ public static Element verbatim( final SVerbatim s) { NullCheck.notNull(s, "Verbatim"); final Element e = new Element("s:verbatim", SXML.XML_URI.toString()); s.getType().map(new TypeAdder(e)); e.appendChild(s.getText()); return e; }
/** * Serialize the given element to XML. * * @param s * The element * @return An XML element */ public static Element paragraph( final SParagraph s) { NullCheck.notNull(s, "Paragraph"); final Element e = new Element("s:paragraph", SXML.XML_URI.toString()); s.getType().map(new TypeAdder(e)); s.getID().map(new IDAdder(e)); for (final SParagraphContent c : s.getContent().getElements()) { e.appendChild(SDocumentSerializer.paragraphContent(c)); } return e; }
/** * Serialize the given element to XML. * * @param s * The element * @return An XML element */ public static Element term( final STerm s) { NullCheck.notNull(s, "Term"); final Element e = new Element("s:term", SXML.XML_URI.toString()); s.getType().map(new TypeAdder(e)); e.appendChild(s.getText().getText()); return e; }
static Element head( final String title, final OptionType<SDocumentStyle> style) { final Element e = new Element("head", SXHTML.XHTML_URI.toString()); final Element e_title = new Element("title", SXHTML.XHTML_URI.toString()); e_title.appendChild(title); e.appendChild(e_title); e.appendChild(SXHTML.stylesheetLink(SResources.CSS_LAYOUT_NAME)); e.appendChild(SXHTML.stylesheetLink(SResources.CSS_COLOUR_NAME)); style.map(new FunctionType<SDocumentStyle, Unit>() { @Override public Unit call( final SDocumentStyle x) { e.appendChild(SXHTML.stylesheetLink(x.getActual().toString())); return Unit.unit(); } }); return e; }
/** * Serialize the given element to XML. * * @param s * The element * @return An XML element */ public static Element sectionWithSubsections( final SSectionWithSubsections s) { NullCheck.notNull(s, "Section"); final Element e = new Element("s:section", SXML.XML_URI.toString()); s.getID().map(new IDAdder(e)); s.getType().map(new TypeAdder(e)); e.appendChild(SDocumentSerializer.sectionTitle(s.getTitle())); s.getContents().map(new FunctionType<SSectionContents, Unit>() { @Override public Unit call( final SSectionContents x) { e.appendChild(SDocumentSerializer.sectionContents(x)); return Unit.unit(); } }); for (final SSubsection c : s.getSubsections().getElements()) { e.appendChild(SDocumentSerializer.subsection(c)); } return e; }
/** * Serialize the given element to XML. * * @param p * The element * @return An XML element */ public static Element part( final SPart p) { NullCheck.notNull(p, "Part"); final Element e = new Element("s:part", SXML.XML_URI.toString()); p.getID().map(new IDAdder(e)); p.getType().map(new TypeAdder(e)); e.appendChild(SDocumentSerializer.partTitle(p.getTitle())); p.getContents().map(new FunctionType<SPartContents, Unit>() { @Override public Unit call( final SPartContents x) { e.appendChild(SDocumentSerializer.partContents(x)); return Unit.unit(); } }); for (final SSection c : p.getSections().getElements()) { e.appendChild(SDocumentSerializer.section(c)); } return e; }
/** * Serialize the given element to XML. * * @param s * The element * @return An XML element */ public static Element sectionWithParagraphs( final SSectionWithParagraphs s) { NullCheck.notNull(s, "Section"); final Element e = new Element("s:section", SXML.XML_URI.toString()); s.getID().map(new IDAdder(e)); s.getType().map(new TypeAdder(e)); e.appendChild(SDocumentSerializer.sectionTitle(s.getTitle())); s.getContents().map(new FunctionType<SSectionContents, Unit>() { @Override public Unit call( final SSectionContents x) { e.appendChild(SDocumentSerializer.sectionContents(x)); return Unit.unit(); } }); for (final SSubsectionContent c : s.getSectionContent().getElements()) { e.appendChild(SDocumentSerializer.subsectionContent(c)); } return e; }
private static void sectionWithSubsections( final SXHTMLSectionContents section_contents_writer, final SLinkProvider link_provider, final SAFormalItemsByKindReadable formals, final SASectionWithSubsections sws, final Element e) throws Exception { final SNonEmptyList<SASubsection> subsections = sws.getSubsections(); sws.getContents().map(new FunctionType<SSectionContents, Unit>() { @Override public Unit call( final SSectionContents x) { e.appendChild(section_contents_writer.getTableOfContents(subsections)); return Unit.unit(); } }); for (final SASubsection ss : subsections.getElements()) { e.appendChild(SXHTML.subsection(link_provider, formals, ss)); } }
static Element image( final SAImage image) { final String[] classes = new String[1]; classes[0] = "image"; final Element e = SXHTML.elementWithClasses("img", image.getType(), classes); image.getHeight().map(new FunctionType<Integer, Unit>() { @Override public Unit call( final Integer x) { e.addAttribute(new Attribute("height", null, x.toString())); return Unit.unit(); } }); image.getWidth().map(new FunctionType<Integer, Unit>() { @Override public Unit call( final Integer x) { e.addAttribute(new Attribute("width", null, x.toString())); return Unit.unit(); } }); e.addAttribute(new Attribute("alt", null, image.getText())); e.addAttribute(new Attribute("src", null, image.getURI().toString())); return e; }
/** * Serialize the given element to XML. * * @param s * The element * @return An XML element */ public static Element listItem( final SListItem s) { NullCheck.notNull(s, "List item"); final Element e = new Element("s:list-item", SXML.XML_URI.toString()); s.getType().map(new TypeAdder(e)); for (final SListItemContent c : s.getContent().getElements()) { e.appendChild(SDocumentSerializer.listItemContent(c)); } return e; }
@Override public Unit visitDocumentWithParts( final SADocumentWithParts document) throws Exception { final SNonEmptyList<SAPart> parts = document.getParts(); doc.getContents().map(new FunctionType<SDocumentContents, Unit>() { @Override public Unit call( final SDocumentContents x) { container.appendChild(doc_contents .getTableOfContentsParts(parts)); return Unit.unit(); } }); for (final SAPart part : parts.getElements()) { container.appendChild(SDocumentXHTMLWriterSingle.part( part_contents, section_contents, link_provider, formals, part)); } return Unit.unit(); }
/** * Serialize the given element to XML. * * @param s * The element * @return An XML element */ public static Element listOrdered( final SListOrdered s) { NullCheck.notNull(s, "List"); final Element e = new Element("s:list-ordered", SXML.XML_URI.toString()); s.getType().map(new TypeAdder(e)); for (final SListItem c : s.getItems().getElements()) { e.appendChild(SDocumentSerializer.listItem(c)); } return e; }
@Override public Unit visitDocumentWithSections( final SADocumentWithSections document) throws Exception { final SNonEmptyList<SASection> sections = document.getSections(); doc.getContents().map(new FunctionType<SDocumentContents, Unit>() { @Override public Unit call( final SDocumentContents x) { container.appendChild(doc_contents .getTableOfContentsSections(sections)); return Unit.unit(); } }); for (final SASection s : sections.getElements()) { container.appendChild(SDocumentXHTMLWriterSingle.section( section_contents, link_provider, formals, s)); } return Unit.unit(); } });
/** * Serialize the given element to XML. * * @param s * The element * @return An XML element */ public static Element formalItem( final SFormalItem s) { NullCheck.notNull(s, "Formal item"); final Element e = new Element("s:formal-item", SXML.XML_URI.toString()); s.getType().map(new TypeAdder(e)); s.getID().map(new IDAdder(e)); final Attribute ak = new Attribute("s:kind", SXML.XML_URI.toString(), s.getKind()); e.addAttribute(ak); e.appendChild(SDocumentSerializer.formalItemTitle(s.getTitle())); e.appendChild(SDocumentSerializer.formalItemContent(s.getContent())); return e; }
/** * Serialize the given element to XML. * * @param s * The element * @return An XML element */ public static Element subsection( final SSubsection s) { NullCheck.notNull(s, "Subsection"); final Element e = new Element("s:subsection", SXML.XML_URI.toString()); s.getID().map(new IDAdder(e)); s.getType().map(new TypeAdder(e)); e.appendChild(SDocumentSerializer.subsectionTitle(s.getTitle())); for (final SSubsectionContent c : s.getContent().getElements()) { e.appendChild(SDocumentSerializer.subsectionContent(c)); } return e; }
/** * Serialize the given element to XML. * * @param s * The element * @return An XML element */ public static Element listUnordered( final SListUnordered s) { NullCheck.notNull(s, "List"); final Element e = new Element("s:list-unordered", SXML.XML_URI.toString()); s.getType().map(new TypeAdder(e)); for (final SListItem c : s.getItems().getElements()) { e.appendChild(SDocumentSerializer.listItem(c)); } return e; }
/** * Serialize the given element to XML. * * @param s * The element * @return An XML element */ public static Element table( final STable s) { NullCheck.notNull(s, "Table"); final Element e = new Element("s:table", SXML.XML_URI.toString()); e.appendChild(SDocumentSerializer.tableSummary(s.getSummary())); s.getHeader().map(new FunctionType<STableHead, Unit>() { @Override public Unit call( final STableHead x) { e.appendChild(SDocumentSerializer.tableHead(x)); return Unit.unit(); } }); e.appendChild(SDocumentSerializer.tableBody(s.getBody())); return e; }
@Override public Unit visitSectionWithSubsections( final SASectionWithSubsections sws) throws Exception { final SNonEmptyList<SASubsection> subsections = sws.getSubsections(); s.getContents().map(new FunctionType<SSectionContents, Unit>() { @Override public Unit call( final SSectionContents x) { try { section_main.appendChild(section_contents .getTableOfContents(subsections)); return Unit.unit(); } catch (final Exception e) { throw new UnreachableCodeException(e); } } }); for (final SASubsection ss : sws.getSubsections().getElements()) { section_main.appendChild(SXHTML.subsection( link_provider, document.getFormals(), ss)); } return Unit.unit(); } });
part.getContents().map(new FunctionType<SPartContents, Unit>() { @Override public Unit call( final SPartContents x)