Terai Atsuhiro 2018-07-09 (月) 17:13:47

Common

verbose

C:\fo\>relaxer -verbose xslfo.rng
Copyright(c) 2000-2004 ASAMI,Tomoharu. All rights reserved.
Relaxer Version 1.1b (20040405) by asami@relaxer.org
Source file     : file:/C:/fo/xslfo.rng
       artifact = IXslStylesheetChoice.java
       artifact = IXslTemplateMixed.java
       artifact = IXslTemplateMixedChoice.java
       artifact = IFoBlockContainerMixed.java

properties

relaxer -properties:hogehoge.properties relax/hoge.rng

dir

  • -dir:./target/src/java
    -dir:c:\temp\target\src
    -dir:file://localhost/c:/temp/target/src
  • dir=./target/src/java
    dir=c:\temp\target\src
    dir=file://localhost/c:/temp/target/src

dir.package

dir=src
dir.package=true
java.package.library=jp.ne.test.hoge.relaxer.lib
src\jp\ne\test\hoge\relaxer\lib

Java

java.package

java.package=jp.ne.test.hoge.relaxer
package jp.ne.test.hoge.relaxer;

java.package.library

java.package.library=jp.ne.test.hoge.relaxer.lib

java.name.class.prefix

  • -java.name.class.prefix:Hoge
  • java.name.class.prefix=Hoge

java.name.class.prefixes

  1. <?xml version="1.0" encoding="Shift_JIS"?>
    <grammar datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
     xmlns="http://relaxng.org/ns/structure/1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:fo="http://www.w3.org/XSL/Format"
    >
    
    
    
  2. #Relaxer.properties
    java.xml.namespace=true
    
                             http://www.w3.org/XSL/Format:Fo
  3. prepare-src:
       [mkdir] Created dir: C:\fo\target\src
        [java] Copyright(c) 2000-2004 ASAMI,Tomoharu. All rights reserved.
        [java] Relaxer Version 1.1b (20040203) by asami@relaxer.org
        [java] Property file       : C:\fo/Relaxer.properties
        [java] Source file : file:/C:/fo/src/relaxng/xslfo.rng
    
        [java]     artifact = XslAttributeSet.java
        [java]     artifact = FoLayoutMasterSet.java
    

Pattern

java.pattern.factory

*1

FoRoot root = new FoRoot();
FondocFactory.setFactory(new XslfonFactory());
IFondocFactory factory = FondocFactory.getFactory();
FoRoot root = factory.createFoRoot();

public class XslfonFactory extends DefaultFondocFactory{
 /**
  * Creates a default <code>FoRoot</code>.
  * This method is a hook method of the AbstractXslfoFactory.
  *
  * @return FoRoot
  */

  /**
   * Creates a default <code>XslTemplate</code>.
   * This method is a hook method of the AbstractFondocFactory.
   *
   * @return XslTemplate
   */
 public XslTemplate createXslTemplate() {
    XslTemplate node = new XslTemplate() {
      public void verify(RVerifyReport report, int index,
                         RVerifyContext context) {
        super.verify(report, index, context);
        report = report.newContext("template");
        String strMatch = getMatch();
        String strName  = getName();
        if(strMatch==null && strName==null) {
          report.addError(
            "@match|@name",index,RVerifyReport.INVALID_VALUE,"","string", 

          );
          return;
        }
      }
    };
    node.rGetRNSContext().declareNamespace(
      "xsl", "http://www.w3.org/1999/XSL/Transform"
    );
    return node;
    //return (new XslTemplate());
  }
}

java.pattern.visitor

MasterNameVisitor mnv = new MasterNameVisitor();
URVisitor.traverse(root, mnv);
//Vector simplePageMasterList = mnv.getSimplePageMasterList();
Vector masterNameList = mnv.getMasterNameList();
JComboBox referenceComboBox = new JComboBox(masterNameList);
public class MasterNameVisitor extends RVisitorBase{
    private final Vector namelist = new Vector();
    private final Vector list = new Vector();
    public Vector getMasterNameList() {
        return namelist;
    }
    public Vector getSimplePageMasterList() {
         return list;
    }
    public boolean enter(FoSimplePageMaster visitable) {
        list.add(visitable);
        namelist.add(visitable.getMasterName());
        Logger.global.info("addMasterNameList "+visitable.getMasterName());
        return(true);
    }
}
XslRoot root = new XslRoot("test.xml");
final Vector namelist = new Vector();
URVisitor.traverse(root, new RVisitorBase() {
  public boolean enter(FoSimplePageMaster visitable) {
    //Logger.global.info("addMasterName "+visitable.getMasterName());
    namelist.add(visitable.getMasterName());
    return(true);
  }
});
JComboBox referenceComboBox = new JComboBox(namelist);

java.pattern.idmap

Swing

java.swing.comboBox(java.swing.list)

<define name="account">
  <element name="account">
    <attribute name="accountNo">
      <choice>
        <value>A12345</value>
        <value>B23456</value>
        <value>C34567</value>
      </choice>
    </attribute>

ComboBoxModel

JComboBox accountNoComboBox = new JComboBox(account.swingComboBoxAccountNo());

http://terai.xrea.jp/data/relaxer/combomodel.png

Java/Extension Grammar

java:role

<?xml version="1.0" encoding="UTF-8" ?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
         xmlns:java="http://www.relaxer.org/xmlns/relaxer/java">
  <start>
    <choice>
      <ref name="person"/>
      <ref name="company"/>
    </choice>
  </start>
  <define name="person">
    <element name="person" java:role="ICommon">
      <ref name="common"/>
    </element>
  </define>
  <define name="company">
    <element name="company" java:role="ICommon">
      <ref name="common"/>
    </element>
  </define>
  <define name="common">
    <attribute name="zip">
      <data type="token"/>
    </attribute>
    <element name="address">
      <data type="token"/>
    </element>
  </define>
</grammar>
<element name="company" java:role="ICommon IFontProperties IBorderProperies">

java:default

 <optional>
   <attribute name="column-count" java:default="1">
     <data type="int"/>
   </attribute>
 </optional>
 <optional>
   <attribute name="column-gap" java:default="12.0pt">
     <data type="string"/>
   </attribute>
 </optional>
 <optional>
   <attribute name="padding-start.conditionality" java:default="discard">
     <choice>
       <value type="NMTOKEN">discard</value>
       <value type="NMTOKEN">retain</value>
     </choice>
   </attribute>
 </optional>
public final String getColumnGap() {
  if (columnGap_ == null) {
    return ("12.0pt");
  }
  return (columnGap_);
}
public final String getPaddingStartConditionality() {
  if (paddingStartConditionality_ == null) {
    return ("discard");
  }
  return (paddingStartConditionality_);
}
<element name="string" java:className="Hoge">
  <empty/>
</element>
public void makeTextElement(StringBuffer buffer) {
    int size;
    buffer.append("<string");
    buffer.append(">");
    buffer.append("</string>");
}
<define name="aaa">
  <element name="aaa" java:extends="jp.ne.hoge.Company"
                      java:implements="jp.ne.hoge.ICompany">
    <ref name="common"/>
  </element>
</define>
public class Aaa extends jp.ne.hoge.Company
  implements jp.ne.hoge.ICompany, java.io.Serializable, Cloneable, IRNode {

java:abstract

<define name="company">
  <element name="company" java:abstract="true"
                          java:extends="jp.ne.hoge.AbstractCompany">
    <ref name="common"/>
  </element>
</define>
public abstract class Company extends jp.ne.hoge.AbstractCompany
  implements java.io.Serializable, Cloneable, IRNode {

java:mapKey

java:code

<define name="account">
  <element name="account">
    <ref name="address"/>
    <zeroOrMore>
      <ref name="phone"/>
    </zeroOrMore>
<java:code xmlns:java="http://www.relaxer.org/xmlns/relaxer/java">
public boolean isOk() {
   return (true);
}
</java:code>
  </element>
</define>