Skip to content

Commit

Permalink
Fix for Concordion API change
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelcharman committed Jul 1, 2018
1 parent 8a4298f commit 5ab1a14
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/main/java/org/concordion/ext/embed/EmbedCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,14 @@

import nu.xom.Document;

import org.concordion.api.AbstractCommand;
import org.concordion.api.CommandCall;
import org.concordion.api.Element;
import org.concordion.api.Evaluator;
import org.concordion.api.ResultRecorder;
import org.concordion.api.*;
import org.concordion.internal.XMLParser;
import org.concordion.internal.util.Check;

/**
* Embeds HTML fragments in the Concordion output.
* <p>
* When embedding HTML, it is often necessary to add namespace declarations to the Concordion output.
* When embedding HTML, it is often necessary to add namespace declarations to the Concordion output.
* The {@link #withNamespace(String, String)} method registers a namespace declaration. When the embed command
* is executed for an element, it creates a wrapper element that contains the namespace declarations around
* the element that the command is being executed for.
Expand All @@ -38,10 +34,10 @@
public class EmbedCommand extends AbstractCommand {

private String namespaceDeclaration = "";

/**
* Registers a namespace declaration.
*
*
* @param prefix the prefix to use for the namespace
* @param namespace the namespace
*/
Expand All @@ -59,9 +55,9 @@ public void withNamespace(String prefix, String namespace) {
}

@Override
public void verify(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder) {
public void verify(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder, Fixture fixture) {
Check.isFalse(commandCall.hasChildCommands(), "Nesting commands inside an 'embed' is not supported");

Object result = evaluator.evaluate(commandCall.getExpression());

Element element = commandCall.getElement();
Expand All @@ -74,7 +70,7 @@ public void verify(CommandCall commandCall, Evaluator evaluator, ResultRecorder
element.appendChild(child);
}
}

private Document getXOMDocument(String xml) {
try {
return XMLParser.parse(String.format("<wrapper %s>%s</wrapper>", namespaceDeclaration, xml));
Expand Down

0 comments on commit 5ab1a14

Please sign in to comment.