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); } }
public Content assemble(ConfigurationContext context) { if (xsltConfiguration == null) { xsltConfiguration = XsltConfiguration.getDefault(); } if (queryFactory == null && stringQueryFactory == null) { String message = MessageFormatter.getInstance() .getMessage( ServingXmlMessages.COMPONENT_ELEMENT_REQUIRED, context.getElement().getTagName(), "sx:stringable or sx:streamSource"); throw new ServingXmlException(message); } if (queryFactory == null) { ValueEvaluator valueEvaluator = new StringValueEvaluator(stringQueryFactory); queryFactory = new StringStreamSourceFactory(valueEvaluator); } if (contextDocument == null) { contextDocument = new DefaultDocument(xsltConfiguration.getOutputPropertyFactories()); } if (baseUri == null) { baseUri = context.getQnameContext().getBase(); } PrefixMap prefixMap = DomHelper.createPrefixMap(context.getElement()); Content contentFactory = new XQueryContent( baseUri, prefixMap, queryFactory, contextDocument, xsltConfiguration.getOutputPropertyFactories()); if (parameterDescriptors.length > 0) { contentFactory = new ContentPrefilter(contentFactory, parameterDescriptors); } return contentFactory; }