protected void on(DAnnotation ann) { if (ann == DAnnotation.EMPTY) return; for (DAnnotation.Attribute attr : ann.getAttributes().values()) { attr(attr.getPrefix(), attr.getNs(), attr.getLocalName(), attr.getValue()); } for (Element elem : ann.getChildren()) { try { newLine(); indent(); print(elem); } catch (XMLStreamException e) { throw new XMLWriterException(e); } } }
public Void onData(DDataPattern p) { List<DDataPattern.Param> params = p.getParams(); DPattern except = p.getExcept(); start("data"); attr("datatypeLibrary", p.getDatatypeLibrary()); attr("type", p.getType()); on(p.getAnnotation()); for (DDataPattern.Param param : params) { start("param"); attr("ns", param.getNs()); attr("name", param.getName()); body(param.getValue()); end(); } if (except != null) { start("except"); unwrapChoice(except); end(); } end(); return null; }
public Void onData(DDataPattern p) { List<DDataPattern.Param> params = p.getParams(); DPattern except = p.getExcept(); start("data"); attr("datatypeLibrary", p.getDatatypeLibrary()); attr("type", p.getType()); on(p.getAnnotation()); for (DDataPattern.Param param : params) { start("param"); attr("ns", param.getNs()); attr("name", param.getName()); body(param.getValue()); end(); } if (except != null) { start("except"); unwrapChoice(except); end(); } end(); return null; }
public Void onGrammar(DGrammarPattern p) { start("grammar"); ns(null, WellKnownNamespaces.RELAX_NG); on(p.getAnnotation()); start("start"); on(p.getStart()); end(); for (DDefine d : p) { start("define"); attr("name", d.getName()); on(d.getAnnotation()); unwrapGroup(d.getPattern()); end(); } end(); return null; }
protected void on(DAnnotation ann) { if (ann == DAnnotation.EMPTY) return; for (DAnnotation.Attribute attr : ann.getAttributes().values()) { attr(attr.getPrefix(), attr.getNs(), attr.getLocalName(), attr.getValue()); } for (Element elem : ann.getChildren()) { try { newLine(); indent(); print(elem); } catch (XMLStreamException e) { throw new XMLWriterException(e); } } }
public Void onGrammar(DGrammarPattern p) { start("grammar"); ns(null, WellKnownNamespaces.RELAX_NG); on(p.getAnnotation()); start("start"); on(p.getStart()); end(); for (DDefine d : p) { start("define"); attr("name", d.getName()); on(d.getAnnotation()); unwrapGroup(d.getPattern()); end(); } end(); return null; }
/** * Prints grammar enclosed by start/end document. * * @param grammar * @throws XMLStreamException */ public void printDocument(DGrammarPattern grammar) throws XMLStreamException { try { visitor.startDocument(); visitor.on(grammar); visitor.endDocument(); } catch (XMLWriterException e) { throw (XMLStreamException) e.getCause(); } }
/** * Prints grammar enclosed by start/end document. * * @param grammar * @throws XMLStreamException */ public void printDocument(DGrammarPattern grammar) throws XMLStreamException { try { visitor.startDocument(); visitor.on(grammar); visitor.endDocument(); } catch (XMLWriterException e) { throw (XMLStreamException) e.getCause(); } }
protected void on(NameClass nc) { if (nc instanceof SimpleNameClass) { QName qname = ((SimpleNameClass) nc).name; String name = qname.getLocalPart(); if (!qname.getPrefix().equals("")) name = qname.getPrefix() + ":"; attr("name", name); } else { nc.accept(ncVisitor); } }
/** * @param out Output stream. */ public DXMLPrinter(XMLStreamWriter out) { this.out = out; this.visitor = new DXMLPrinterVisitor(); this.ncVisitor = new NameClassXMLPrinterVisitor(); this.domPrinter = new DOMPrinter(out); }
protected void on(NameClass nc) { if (nc instanceof SimpleNameClass) { QName qname = ((SimpleNameClass) nc).name; String name = qname.getLocalPart(); if (!qname.getPrefix().equals("")) name = qname.getPrefix() + ":"; attr("name", name); } else { nc.accept(ncVisitor); } }
/** * @param out Output stream. */ public DXMLPrinter(XMLStreamWriter out) { this.out = out; this.visitor = new DXMLPrinterVisitor(); this.ncVisitor = new NameClassXMLPrinterVisitor(); this.domPrinter = new DOMPrinter(out); }
public Void onZeroOrMore(DZeroOrMorePattern p) { start("zeroOrMore"); on(p.getAnnotation()); unwrapGroup(p.getChild()); end(); return null; } }
public Void onOptional(DOptionalPattern p) { start("optional"); on(p.getAnnotation()); unwrapGroup(p.getChild()); end(); return null; }