---
title: "object(byApplyingXSLTString:arguments:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/xmldocument/object(byapplyingxsltstring:arguments:)"
---

# object(byApplyingXSLTString:arguments:)

Applies the XSLT pattern rules and templates (specified as a string) to the receiver and returns a document object containing transformed XML or HTML markup.

## Declaration

```swift
func object(byApplyingXSLTString xslt: String, arguments: [String : String]?) throws -> Any
```

## Parameters

- `xslt`: A string object containing the XSLT pattern rules and templates.
- `arguments`: A dictionary containing doc://com.apple.foundation/documentation/Foundation/NSString key-value pairs that are passed as runtime parameters to the XSLT processor. Pass in nil if you have no parameters to pass. note: Several XML websites discuss XSLT parameters, including O’Reilly Media’s http://www.xml.com.

## Return Value

Return Value Depending on intended output, the method returns an NSXMLDocument object or an NSData data containing transformed XML or HTML markup. If the message is supposed to create plain text or RTF, then an NSData object is returned, otherwise an XML document object. The method returns  nil if XSLT processing did not succeed.

## Discussion

Discussion note: In Swift, this method returns a nonoptional result and is marked with the throws keyword to indicate that it throws an error in cases of failure. You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.

## See Also

### Transforming a Document Using XSLT

- [object(byApplyingXSLT:arguments:)](foundation/xmldocument/object(byapplyingxslt:arguments:).md)
- [objectByApplyingXSLT(at:arguments:)](foundation/xmldocument/objectbyapplyingxslt(at:arguments:).md)
