コード例 #1
0
  public MapXmlFactory assemble(ConfigurationContext context) {

    if (elementQname == null || elementQname.length() == 0) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ATTRIBUTE_REQUIRED,
                  context.getElement().getTagName(),
                  "element");
      throw new ServingXmlException(message);
    }

    try {
      if (xsltConfiguration == null) {
        xsltConfiguration = XsltConfiguration.getDefault();
      }

      NameSubstitutionExpr nameResolver =
          NameSubstitutionExpr.parse(context.getQnameContext(), elementQname);

      StringFactory stringFactory =
          StringFactoryCompiler.fromStringables(context, context.getElement());
      StringFactory[] stringFactories = new StringFactory[] {stringFactory};

      MapXmlFactory rmf =
          new MultipleMapXmlFactory(context.getQnameContext(), xsltConfiguration, childFactories);

      if (sorts.length > 0) {
        Comparator comparator = new SortComparator(sorts);
        rmf = new SortGroupFactory(rmf, comparator);
      }
      Environment env = new Environment(parameterDescriptors, context.getQnameContext());
      MapXmlFactory recordMapFactory =
          new ElementMapFactory(env, nameResolver, stringFactories, rmf);
      return recordMapFactory;
    } catch (ServingXmlException e) {
      throw e.contextualizeMessage(context.getElement().getTagName());
    } catch (Exception e) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ERROR,
                  context.getElement().getTagName(),
                  e.getMessage());
      throw new ServingXmlException(message, e);
    }
  }
コード例 #2
0
  public boolean hasName(Name name) {

    return nameResolver.hasName(name);
  }
コード例 #3
0
 public Name createName(Record record) {
   return nameResolver.evaluateName(Record.EMPTY, record);
 }
コード例 #4
0
  public RecordCombinationFactory assemble(ConfigurationContext context) {
    Environment env = new Environment(parameterDescriptors, context.getQnameContext());

    if (recordTypeName.length() == 0) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ATTRIBUTE_REQUIRED,
                  context.getElement().getTagName(),
                  "recordType");
      throw new ServingXmlException(message);
    }

    NameSubstitutionExpr recordTypeNameExpr =
        NameSubstitutionExpr.parse(context.getQnameContext(), recordTypeName);

    if (dataRecordTypeFactory == null) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ELEMENT_REQUIRED,
                  context.getElement().getTagName(),
                  "sx:flatRecordType");
      throw new ServingXmlException(message);
    }

    if (repeatingGroupFieldName.isEmpty()) {
      String msg =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ATTRIBUTE_REQUIRED,
                  context.getElement().getTagName(),
                  "repeatingGroup");
      throw new ServingXmlException(msg);
    }

    String baseUri = context.getQnameContext().getBase();
    XPathBooleanExpressionFactory startTestFactory;
    if (startTest.length() > 0) {
      startTestFactory =
          new XPathBooleanExpressionFactoryImpl(
              context.getQnameContext(),
              startTest,
              xsltConfiguration.getVersion(),
              baseUri,
              xsltConfiguration.getTransformerFactory());
    } else {
      startTestFactory =
          new SimpleXPathBooleanExpressionFactory(XPathBooleanExpression.ALWAYS_TRUE);
    }
    XPathBooleanExpressionFactory endTestFactory;
    if (endTest.length() > 0) {
      endTestFactory =
          new XPathBooleanExpressionFactoryImpl(
              context.getQnameContext(),
              endTest,
              xsltConfiguration.getVersion(),
              baseUri,
              xsltConfiguration.getTransformerFactory());
    } else {
      endTestFactory = startTestFactory;
    }

    GroupRecognizer groupRecognizer =
        new GroupRecognizerImpl(
            env.getQnameContext().getPrefixMap(), startTestFactory, endTestFactory);

    FlatFileOptionsFactory flatFileOptionsFactory = assembleFlatFileOptions(context);

    RecordCombinationFactory recordCompositionFactory =
        new CombineFlatRecordsFactory(
            recordTypeNameExpr,
            repeatingGroupFieldName,
            groupRecognizer,
            dataRecordTypeFactory,
            flatFileOptionsFactory);
    // if (parameterDescriptors.length > 0) {
    //  recordCompositionFactory = new FlatRecordTypeFactoryPrefilter(recordCompositionFactory,
    //                                                         parameterDescriptors);
    // }
    return recordCompositionFactory;
  }