public XNode serializeToXNode() throws SchemaException { if (xnode != null) { // QName type = xnode.getTypeQName(); // if (xnode instanceof PrimitiveXNode && type != null){ // if (!((PrimitiveXNode)xnode).isParsed()){ // Object realValue = PrismUtil.getXnodeProcessor(prismContext).parseAnyValue(xnode, ParsingContext.createDefault()); // ((PrimitiveXNode)xnode).setValue(realValue, type); // } // } return xnode; } else if (parsed != null) { checkPrismContext(); XNode rv = prismContext.xnodeSerializer().root(new QName("dummy")).serialize(parsed).getSubnode(); prismContext.xnodeMutator().setXNodeType(rv, explicitTypeName, explicitTypeDeclaration); return rv; } else { return null; // or an exception here? } } //endregion