Forums
daveboden
Forum Replies Created
-
AuthorPosts
-
January 9, 2013 at 9:34 am in reply to: JAXB issue – parse
elements without a workaround – 5.4 – match and clear ids #2085 davebodenSpectatorWorked 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; }
-
AuthorPosts
Forum Replies Created
-
AuthorPosts
-
January 9, 2013 at 9:34 am in reply to: JAXB issue – parse
elements without a workaround – 5.4 – match and clear ids #2085 davebodenSpectatorWorked 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; }
-
AuthorPosts
Search Forums
Recent Topics
-
Repo vs Reverse Repo
3 years, 4 months ago
-
resetFrequency for SOFR OIS
3 years, 9 months ago
-
FXD Option on strategy
4 years ago
-
Forward Exercise
4 years, 4 months ago
-
Usage of IRSwap in Confirmation Process (requestConfirmation)
4 years, 3 months ago