class XACMLSchemaFactory {

    public AdviceExpression resourceAttributeToAdviceExpression(ResourceAttribute resourceAttribute)
            throws EntitlementException {

        // A pseudo-urn to use for advice/attribute id
        final String adviceId = XACMLConstants.JSON_RESOURCE_ATTRIBUTE_ADVICE_ID + ":" + resourceAttribute.getClass()
                .getName();

        AdviceExpression result = new AdviceExpression();

        AttributeValue attributeValue = factory.createAttributeValue();
        attributeValue.setDataType(XACMLConstants.XS_STRING);

        // We bypass much of the grief of conversion by getting JSON to do the heavy lifting for us.
        attributeValue.getContent().add(resourceAttributeUtil.toJSON(resourceAttribute));
        JAXBElement<AttributeValue> jaxbElement = factory.createAttributeValue(attributeValue);

        AttributeAssignmentExpression attributeAssignmentExpression = factory.createAttributeAssignmentExpression();
        attributeAssignmentExpression.setExpression(jaxbElement);
        attributeAssignmentExpression.setAttributeId(adviceId + ":" + resourceAttribute.getPropertyName());
        result.getAttributeAssignmentExpression().add(attributeAssignmentExpression);

        // Resource Attributes are returned on successful policy decisions
        result.setAppliesTo(EffectType.PERMIT);

        // Set an AdviceId to be in strict compliance with the schema
        result.setAdviceId(adviceId);

        return result;
    }

    public  XACMLSchemaFactory();

}