Forums

FpML Discussion

General FpML Discussion FpML Version 5.0 (Closed for Posting) JAXB issue – parse elements without a workaround – 5.4 – match and clear ids

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2081
    daveboden
    Spectator

    JAXB has an issue (bug) which makes parsing elements in FPML difficult: http://java.net/jira/browse/JAXB-793 I’m in the process of implementing a workaround (I’ll update the JAXB Bug Tracker with the workaround and might post it here too) and will try to prepare a bug-fix or at least a reproducable JUnit test for JAXB. In the meantime, we should assume that JAXB won’t be able to easily support the FPML tag for the next few months at least. A reasonable position to take would be “this is a tools problem, no change required in the FPML schema”. However, that overlooks two points: * A large proportion of users of the FPML schema are going to be using JAXB to unmarshal XML. * The schema as it stands doesn’t allow for good tools support. Even when JAXB is fixed the fact that there are two separate logical types that are represented by the same tag is going to present a challenge for tools. Why not have different types rather than a “choice”? I’d invite other FPML users who are currently implementing Dodd Frank requirements around “USI”s to comment on this post if they’re experiencing the same problem.

    #2085
    daveboden
    Spectator

    Worked around the issue by resorting to using XPath to separately pull out the trade identifiers. Sun’s implementation of JAXB probably won’t ever support this schema; please see my comments on the JAXB bug. Here’s an overview of the workaround: private final NamespaceContext namespaceContext = new MarkitServNamespacePrefixMapper(); //When receiving a message: NodeList messages = (NodeList)xpath.evaluate(“/env:Envelope/env:Body/mtc:OTC_Matching/*”, new InputSource(new StringReader(fpml)), XPathConstants.NODESET) if(messages != null && otcMatchings.size() != 0) { if(messages.getLength() != otcMatchings.size()) { throw new RuntimeException( String.format(“Error – JAXB reported %d sub-messaages but XPath reported %d”, otcMatchings.size(), messages.getLength() ) ); } } Then a method to pull out the ID based on scheme: private String parseId(Node message, String idScheme) { XPath xpath = xpathThreadLocal.get(); String matchId; try { matchId = xpath.evaluate(“//fpml:tradeReferenceInformation/fpml:partyTradeIdentifier/fpml:tradeId[@tradeIdScheme='” + idScheme + “‘]”, message); } catch (XPathExpressionException ex) { throw new RuntimeException(“Error parsing id of type: ” + idScheme, ex); } return matchId; }

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘FpML Version 5.0 (Closed for Posting)’ is closed to new topics and replies.