# Learning from existing components

## Finding existing components

A good thing to do is to look at existing components:

* If you are working with the Orbeon Forms sources, most components are located under:
  * [form-runner/jvm/src/main/resources/xbl](https://github.com/orbeon/orbeon-forms/tree/master/form-runner/jvm/src/main/resources/xbl)
* If you are working with a binary distribution:
  * unzip `orbeon-resources-private.jar`
  * the components are under the `xbl` directory

The "meat" of most components is in files ending with the `.xbl` extension.

## Creating your own component

* create a new `xbl` directory under your RESOURCES directory
* create a directory with your company or project name (e.g. `acme`; Orbeon uses `orbeon`)
* create directory with your new component name (e.g. `cool-stuff`)
* create a new XBL file with the same name in that directory, e.g. `cool-stuff.xbl`
* so you should have: `xbl/acme/cool-stuff/cool-stuff.xbl`

Then:

* copy into your XBL file the content of a simple existing component, like [`tutorial-input.xbl`](https://github.com/orbeon/orbeon-forms/blob/master/form-runner/jvm/src/main/resources/xbl/orbeon/tutorial-input/tutorial-input.xbl)
* modify the binding rule (`fr|tutorial-simple`) into something that matches your component name (`fr|cool-stuff`)
* within an XForms page
  * declare `xmlns:fr="http://orbeon.org/oxf/xml/form-runner"`
  * use the control with something like: `<fr:cool-stuff ref="my-node">`
  * when running your XForms page, you should see an upload field appear!

*NOTE: In your own components, you should not use the* `fr:` *namespace, but instead you should use your own namespace to avoid naming conflicts.*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.orbeon.com/xforms/xbl/guide/learning-from-existing-components.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
