Index: src/main/java/org/xwiki/model/internal/scripting/ModelScriptService.java
===================================================================
--- src/main/java/org/xwiki/model/internal/scripting/ModelScriptService.java	(revision 31281)
+++ src/main/java/org/xwiki/model/internal/scripting/ModelScriptService.java	(working copy)
@@ -25,9 +25,11 @@
 import org.xwiki.component.manager.ComponentLookupException;
 import org.xwiki.component.manager.ComponentManager;
 import org.xwiki.model.EntityType;
+import org.xwiki.model.reference.AttachmentReference;
 import org.xwiki.model.reference.DocumentReference;
 import org.xwiki.model.reference.DocumentReferenceResolver;
 import org.xwiki.model.reference.EntityReference;
+import org.xwiki.model.reference.EntityReferenceResolver;
 import org.xwiki.model.reference.EntityReferenceSerializer;
 import org.xwiki.script.service.ScriptService;
 
@@ -40,6 +42,14 @@
 @Component("model")
 public class ModelScriptService implements ScriptService
 {
+    /**
+     * The default hint used when resolving string references.
+     */
+    private static final String DEFAULT_STRING_RESOLVER_HINT = "currentmixed";
+
+    /**
+     * Used to dynamically look up component implementations based on a given hint.
+     */
     @Requirement
     private ComponentManager componentManager;
 
@@ -49,7 +59,7 @@
      * 
      * @param wiki the wiki reference name to use (can be empty or null)
      * @param space the space reference name to use (can be empty or null)
-     * @param page the page referene name to use (can be empty or null)
+     * @param page the page reference name to use (can be empty or null)
      * @return the typed Document Reference object or null if no Resolver with the passed hint could be found
      * @since 2.3M2
      */
@@ -65,10 +75,11 @@
      * 
      * @param wiki the wiki reference name to use (can be empty or null)
      * @param space the space reference name to use (can be empty or null)
-     * @param page the page referene name to use (can be empty or null)
+     * @param page the page reference name to use (can be empty or null)
      * @param hint the hint of the Resolver to use in case any parameter is empty or null
      * @return the typed Document Reference object or null if no Resolver with the passed hint could be found
      */
+    @SuppressWarnings("unchecked")
     public DocumentReference createDocumentReference(String wiki, String space, String page, String hint)
     {
         EntityReference reference = null;
@@ -92,35 +103,83 @@
     }
 
     /**
+     * Creates an {@link AttachmentReference} from a file name and a reference to the document holding that file.
+     * 
+     * @param fileName the name of a file attached to a document
+     * @param documentReference a reference to the document the file is attached to
+     * @return a reference to the specified attachment
+     * @since 2.5M2
+     */
+    public AttachmentReference createAttachmentReference(String fileName, DocumentReference documentReference)
+    {
+        return new AttachmentReference(fileName, documentReference);
+    }
+
+    /**
      * @param stringRepresentation the document reference specified as a String (using the "wiki:space.page" format and
-     *            with special characters escaped where required).
-     * @return the typed Document Reference object (resolved using the "currentmixed" resolver)
+     *            with special characters escaped where required)
+     * @return the typed Document Reference object (resolved using the {@value #DEFAULT_STRING_RESOLVER_HINT} resolver)
      * @since 2.3M2
      */
     public DocumentReference resolveDocument(String stringRepresentation)
     {
-        return resolveDocument(stringRepresentation, "currentmixed");
+        return resolveDocument(stringRepresentation, DEFAULT_STRING_RESOLVER_HINT);
     }
 
     /**
      * @param stringRepresentation the document reference specified as a String (using the "wiki:space.page" format and
-     *            with special characters escaped where required).
+     *            with special characters escaped where required)
      * @param hint the hint of the Resolver to use in case any part of the reference is missing (no wiki specified, no
      *            space or no page)
+     * @param parameters extra parameters to pass to the resolver; you can use these parameters to resolve a document
+     *            reference relative to another entity reference
      * @return the typed Document Reference object or null if no Resolver with the passed hint could be found
      */
-    public DocumentReference resolveDocument(String stringRepresentation, String hint)
+    @SuppressWarnings("unchecked")
+    public DocumentReference resolveDocument(String stringRepresentation, String hint, Object... parameters)
     {
-        DocumentReference result;
         try {
-            result = this.componentManager.lookup(DocumentReferenceResolver.class, hint).resolve(stringRepresentation);
+            EntityReferenceResolver<String> resolver = componentManager.lookup(EntityReferenceResolver.class, hint);
+            return new DocumentReference(resolver.resolve(stringRepresentation, EntityType.DOCUMENT, parameters));
         } catch (ComponentLookupException e) {
-            result = null;
+            return null;
         }
-        return result;
     }
 
     /**
+     * @param stringRepresentation an attachment reference specified as {@link String} (using the "wiki:space.page@file"
+     *            format and with special characters escaped where required)
+     * @return the corresponding typed {@link AttachmentReference} object (resolved using the
+     *         {@value #DEFAULT_STRING_RESOLVER_HINT} resolver)
+     * @since 2.5M2
+     */
+    public AttachmentReference resolveAttachment(String stringRepresentation)
+    {
+        return resolveAttachment(stringRepresentation, DEFAULT_STRING_RESOLVER_HINT);
+    }
+
+    /**
+     * @param stringRepresentation an attachment reference specified as {@link String} (using the "wiki:space.page@file"
+     *            format and with special characters escaped where required)
+     * @param hint the hint of the resolver to use in case any part of the reference is missing (no wiki specified, no
+     *            space or no page)
+     * @param parameters extra parameters to pass to the resolver; you can use these parameters to resolve an attachment
+     *            reference relative to another entity reference
+     * @return the corresponding typed {@link AttachmentReference} object
+     * @since 2.5M2
+     */
+    @SuppressWarnings("unchecked")
+    public AttachmentReference resolveAttachment(String stringRepresentation, String hint, Object... parameters)
+    {
+        try {
+            EntityReferenceResolver<String> resolver = componentManager.lookup(EntityReferenceResolver.class, hint);
+            return new AttachmentReference(resolver.resolve(stringRepresentation, EntityType.ATTACHMENT, parameters));
+        } catch (ComponentLookupException e) {
+            return null;
+        }
+    }
+
+    /**
      * @param reference the entity reference to transform into a String representation
      * @return the string representation of the passed entity reference (using the "compact" serializer)
      * @since 2.3M2
