Skip to content

Commit

Permalink
streamline formatting: programs and subprograms capitalized in text a…
Browse files Browse the repository at this point in the history
…nd code, types lower-case
  • Loading branch information
gvasquezvargas committed Nov 28, 2024
1 parent 50e2482 commit 0bd91bd
Show file tree
Hide file tree
Showing 19 changed files with 259 additions and 259 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
s---
---
title: "SUBSTR"
redirects:
- /epas/latest/epas_compat_bip_guide/03_built-in_packages/06_dbms_lob/11_substr/ #generated for docs/epas/reorg-role-use-case-mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ APPENDCHILD(n DOMNode, newChild IN DOMNode) RETURN DOMNode

`n`

The DOMNODE where the new node is to be added.
The `DOMNode` where the new node is to be added.

`newchild`

Expand All @@ -24,16 +24,16 @@ This example creates a new XML DOMDocument named `l_domdoc` and a new DOMElement

```sql
DECLARE
l_domdoc dbms_xmldom.DOMDocument;
l_department_element dbms_xmldom.DOMElement;
l_domdoc DBMS_XMLDOM.DOMDocument;
l_department_element DBMS_XMLDOM.DOMElement;
l_xmltype XMLTYPE;


BEGIN
l_domdoc := dbms_xmldom.NewDOMDocument();
l_department_element := dbms_xmldom.createElement(l_domdoc, 'Departments' );
PERFORM dbms_xmldom.appendChild(dbms_xmldom.makeNode(l_domdoc), dbms_xmldom.makeNode(l_department_element));
l_xmltype := dbms_xmldom.getXmlType(l_domdoc);
l_domdoc := DBMS_XMLDOM.NEWDOMDOCUMENT();
l_department_element := DBMS_XMLDOM.CREATEELEMENT(l_domdoc, 'Departments' );
PERFORM DBMS_XMLDOM.appendChild(DBMS_XMLDOM.MAKENODE(l_domdoc), DBMS_XMLDOM.MAKENODE(l_department_element));
l_xmltype := DBMS_XMLDOM.GETXMLTYPE(l_domdoc);
DBMS_OUTPUT.PUT_LINE(l_xmltype.getStringVal());
END;
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@
title: "CREATEELEMENT"
---

The `CREATEELEMENT` function creates and returns a DOMELEMENT.
The `CREATEELEMENT` function creates and returns a DOMElement.

```
CREATEELEMENT( doc DOMDOCUMENT, tagname IN VARCHAR2) RETURN DOMELEMENT
CREATEELEMENT( doc DOMDocument, tagname IN VARCHAR2) RETURN DOMElement
```

## Parameters

`doc`

Any DOMDOCUMENT
Any `DOMDocument`.

`tagname`

Tag name to be given to the new DOMELEMENT.
Tag name to be given to the new `DOMDocument`.

## Examples

This example creates a new XML DOMDocument named `l_domdoc` and a new DOMElement named `l_department_element` with tag name `Departments`. It then appends the DOMElement as a child of the DOMDocument.

```sql
DECLARE
l_domdoc dbms_xmldom.DOMDocument;
l_department_element dbms_xmldom.DOMElement;
l_domdoc DBMS_XMLDOM.DOMDocument;
l_department_element DBMS_XMLDOM.DOMElement;
l_xmltype XMLTYPE;


BEGIN
l_domdoc := dbms_xmldom.NewDOMDocument();
l_department_element := dbms_xmldom.createElement(l_domdoc, 'Departments' );
PERFORM dbms_xmldom.appendChild(dbms_xmldom.makeNode(l_domdoc), dbms_xmldom.makeNode(l_department_element));
l_xmltype := dbms_xmldom.getXmlType(l_domdoc);
l_domdoc := DBMS_XMLDOM.NEWDOMDOCUMENT();
l_department_element := DBMS_XMLDOM.CREATEELEMENT(l_domdoc, 'Departments' );
PERFORM DBMS_XMLDOM.APPENDCHILD(DBMS_XMLDOM.MAKENODE(l_domdoc), DBMS_XMLDOM.MAKENODE(l_department_element));
l_xmltype := DBMS_XMLDOM.GETXMLTYPE(l_domdoc);
DBMS_OUTPUT.PUT_LINE(l_xmltype.getStringVal());
END;
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,44 @@
title: "CREATETEXTNODE"
---

The `CREATETEXTNODE` function creates and returns a DOMTEXT node.
The `CREATETEXTNODE` function creates and returns a DOMText node.

```
CREATETEXTNODE( doc DOMDOCUMENT, data IN VARCHAR2) RETURN DOMTEXT
CREATETEXTNODE( doc DOMDocument, data IN VARCHAR2) RETURN DOMText
```

## Parameters

`doc`

Any DOMDOCUMENT
Any `DOMDocument`.

`data`

Content provided for the DOMTEXT node.
Content provided for the `DOMText` node.

## Examples

This example creates a new XML DOMDocument, a DOMElement with tag name “Departments” and a text node with “Depts list” as its value. The DOMElement is appended as a child to the DOMDocument, and the text node as a child to the DOMElement.
This example creates a new XML `DOMDocument`, a `DOMElement` with tag name “Departments” and a text node with “Depts list” as its value. The `DOMElement` is appended as a child to the `DOMDocument`, and the text node as a child to the `DOMElement`.

```sql
DECLARE
l_domdoc dbms_xmldom.DOMDocument;
l_root_node dbms_xmldom.DOMNode;
l_department_element dbms_xmldom.DOMElement;
l_departments_node dbms_xmldom.DOMNode;
l_name_text dbms_xmldom.DOMText;
l_domdoc DBMS_XMLDOM.DOMDocument;
l_root_node DBMS_XMLDOM.DOMNode;
l_department_element DBMS_XMLDOM.DOMElement;
l_departments_node DBMS_XMLDOM.DOMNode;
l_name_text DBMS_XMLDOM.DOMText;
l_xmltype XMLTYPE;


BEGIN
l_domdoc := dbms_xmldom.newDomDocument;
l_root_node := dbms_xmldom.makeNode(l_domdoc);
l_department_element := dbms_xmldom.createElement(l_domdoc, 'Departments' );
l_departments_node := dbms_xmldom.appendChild(l_root_node,dbms_xmldom.makeNode(l_department_element));
l_name_text := dbms_xmldom.createTextNode(l_domdoc, 'Depts list' );
PERFORM dbms_xmldom.appendChild(l_departments_node,dbms_xmldom.makeNode(l_name_text));
l_xmltype := dbms_xmldom.getXmlType(l_domdoc);
l_domdoc := DBMS_XMLDOM.NEWDOMDOCUMENT;
l_root_node := DBMS_XMLDOM.MAKENODE(l_domdoc);
l_department_element := DBMS_XMLDOM.CREATEELEMENT(l_domdoc, 'Departments' );
l_departments_node := DBMS_XMLDOM.APPENDCHILD(l_root_node,DBMS_XMLDOM.MAKENODE(l_department_element));
l_name_text := DBMS_XMLDOM.CREATETEXTNODE(l_domdoc, 'Depts list' );
PERFORM DBMS_XMLDOM.APPENDCHILD(l_departments_node,DBMS_XMLDOM.MAKENODE(l_name_text));
l_xmltype := DBMS_XMLDOM.GETXMLTYPE(l_domdoc);
DBMS_OUTPUT.PUT_LINE(l_xmltype.getStringVal());
END;
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "FREEDOCUMENT"
---

The `FREEDOCUMENT` procedure is used to free the DOMDOCUMENT object.
The `FREEDOCUMENT` procedure is used to free the `DOMDocument` object.

```
FREEDOCUMENT(doc IN DOMDocument)
Expand All @@ -12,22 +12,22 @@ FREEDOCUMENT(doc IN DOMDocument)

`doc`

The DOMDOCUMENT to be made free.
The `DOMDocument` to be made free.


## Examples

This example creates a new DOMDocument, which is not accessible after it has been freed.
This example creates a new `DOMDocument`, which is not accessible after it has been freed.

```sql
DECLARE
l_domdoc dbms_xmldom.DOMDocument;
l_domdoc DBMS_XMLDOM.DOMDocument;


BEGIN
l_domdoc := dbms_xmldom.newDOMDocument();
dbms_xmldom.freeDocument(l_domdoc);
dbms_xmldom.setversion(l_domdoc, '1.0');
l_domdoc := DBMS_XMLDOM.NEWDOMDOCUMENT();
DBMS_XMLDOM.FREEDOCUMENT(l_domdoc);
DBMS_XMLDOM.SETVERSION(l_domdoc, '1.0');
END;
/
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "GETATTRIBUTE"
---

The `GETATTRIBUTE` function returns the value of an attribute of an DOMELEMENT by name.
The `GETATTRIBUTE` function returns the value of an attribute of an `DOMElement` by name.

```
GETATTRIBUTE(elem DOMElement, name IN VARCHAR2) RETURN VARCHAR2
Expand All @@ -14,57 +14,57 @@ GETATTRIBUTE(elem DOMElement, name IN VARCHAR2, ns IN VARCHAR2) RETURN VARCHAR2

`elem`

The DOMELEMENT whose attribute needs to be obtained.
The `DOMElement` whose attribute needs to be obtained.

`name`

The attribute name which needs to be obtained.

`ns`

The namespace URI
The namespace URI.

## Examples

This example creates a new DOMDocument named `l_domdoc`, and a DOMElement named `elem` with tag name “Departments”. It then adds an attribute to the DOMElement named ‘value’. The example turns both `l_domdoc` and `elem` to DOMNodes to append `elem` as a child of `l_domdoc`. Finally, it converts `l_domdoc` to `XMLType`.
This example creates a new `DOMDocument` named `l_domdoc`, and a `DOMElement` named `elem` with tag name “Departments”. It then adds an attribute to the `DOMElement` named ‘value’. The example turns both `l_domdoc` and `elem` to `DOMNodes` to append `elem` as a child of `l_domdoc`. Finally, it converts `l_domdoc` to `XMLType`.

The `get` subprogram returns the value of the attribute `attr` of the "Departments" element.


```sql
DECLARE
l_xml xmltype;
l_domdoc dbms_xmldom.DOMDocument;
l_departments_node dbms_xmldom.DOMNode;
elem dbms_xmldom.DOMElement;
l_xml XMLType;
l_domdoc DBMS_XMLDOM.DOMDocument;
l_departments_node DBMS_XMLDOM.DOMNode;
elem DBMS_XMLDOM.DOMElement;
BEGIN
l_domdoc := dbms_xmldom.newDomDocument;
elem := dbms_xmldom.createElement(l_domdoc, 'Departments' );
dbms_xmldom.setAttribute(elem, 'attr', 'value');
PERFORM dbms_xmldom.appendchild(dbms_xmldom.makeNode(l_domdoc), dbms_xmldom.makeNode(elem));
l_xml := dbms_xmldom.getxmltype(l_domdoc);
l_domdoc := DBMS_XMLDOM.NEWDOMDOCUMENT;
elem := DBMS_XMLDOM.CREATEELEMENT(l_domdoc, 'Departments' );
DBMS_XMLDOM.SETATTRIBUTE(elem, 'attr', 'value');
PERFORM DBMS_XMLDOM.APPENDCHILD(DBMS_XMLDOM.MAKENODE(l_domdoc), DBMS_XMLDOM.MAKENODE(elem));
l_xml := DBMS_XMLDOM.GETXMLTYPE(l_domdoc);
dbms_output.put_line(l_xml.getStringVal());
dbms_output.put_line(dbms_xmldom.getattribute(elem, 'attr'));
dbms_output.put_line(DBMS_XMLDOM.GETATTRIBUTE(elem, 'attr'));
END;
```

This example defines a namespace named “example” and uses an XMLtype string to create an XML structure. `GETFIRSTCHILD` then returns a `DOMNODE` that represents a `DOMELEMENT`. Since `GETATTRIBUTE` expects a `DOMELEMENT`, the `MAKEELEMENT` function converts a specified `DOMNODE` into a `DOMELEMENT` and returns it.
This example defines a namespace named “example” and uses an XMLtype string to create an XML structure. `GETFIRSTCHILD` then returns a `DOMNode` that represents a `DOMElement`. Since `GETATTRIBUTE` expects a `DOMElement`, the `MAKEELEMENT` function converts a specified `DOMNode` into a `DOMElement` and returns it.

```sql
DECLARE
l_domdoc dbms_xmldom.DOMDocument;
l_departments_node dbms_xmldom.DOMNode;
item_node dbms_xmldom.DOMNode;
l_domdoc DBMS_XMLDOM.DOMDocument;
l_departments_node DBMS_XMLDOM.DOMNode;
item_node DBMS_XMLDOM.DOMNode;
BEGIN
l_domdoc := dbms_xmldom.newDOMDocument(XMLTYPE('<b:collection xmlns:b="example:namespace"><b:item b:type="primary" b:id="[email protected]"></b:item></b:collection>'));
l_domdoc := DBMS_XMLDOM.NEWDOMDOCUMENT(XMLTYPE('<b:collection xmlns:b="example:namespace"><b:item b:type="primary" b:id="[email protected]"></b:item></b:collection>'));


l_departments_node := DBMS_XMLDOM.getfirstchild(dbms_xmldom.makeNode(l_domdoc));
item_node := dbms_xmldom.getfirstchild(l_departments_node);
dbms_output.put_line('item node: ' || dbms_xmldom.getnodename(item_node));
dbms_output.put_line('item attr: ' || dbms_xmldom.getattribute(dbms_xmldom.makeelement(item_node), 'id', 'example:namespace'));
l_departments_node := DBMS_XMLDOM.GETFIRSTCHILD(DBMS_XMLDOM.MAKENODE(l_domdoc));
item_node := DBMS_XMLDOM.GETFIRSTCHILD(l_departments_node);
dbms_output.put_line('item node: ' || DBMS_XMLDOM.GETNODENAME(item_node));
dbms_output.put_line('item attr: ' || DBMS_XMLDOM.GETATTRIBUTE(DBMS_XMLDOM.MAKEELEMENT(item_node), 'id', 'example:namespace'));


dbms_xmldom.freeDocument(l_domdoc);
DBMS_XMLDOM.FREEDOCUMENT(l_domdoc);
END;
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "GETCHILDNODES"
---

The `GETCHILDNODES` function retrieves a DOMENODELIST that has all the children of the particular node. If no children are there, then the DOMENODELIST doesn't contain nodes.
The `GETCHILDNODES` function retrieves a `DOMNodeList` that has all the children of the particular node. If no children are there, then the `DOMNodeList` doesn't contain nodes.

```
GETCHILDNODES(n DOMNode) RETURN DOMNodeList
Expand All @@ -12,40 +12,40 @@ GETCHILDNODES(n DOMNode) RETURN DOMNodeList

`n`

The DOMNODE whose childnode list is to be retrieved.
The `DOMNode` whose childnode list is to be retrieved.

## Examples

This example executes a function named `func1` that creates the XML structure `<Deptartments>Dept1</Deptartments>` and returns the root node which is a DOMDocument.
This example executes a function named `func1` that creates the XML structure `<Deptartments>Dept1</Deptartments>` and returns the root node which is a `DOMDocument`.

```sql
CREATE OR REPLACE FUNCTION func1 RETURN dbms_xmldom.DOMNode IS
l_domdoc dbms_xmldom.DOMDocument;
l_root_node dbms_xmldom.DOMNode;
l_department_element dbms_xmldom.DOMElement;
l_departments_node dbms_xmldom.DOMNode;
l_name_text dbms_xmldom.DOMText;
l_name_textnode dbms_xmldom.DOMNode;
CREATE OR REPLACE FUNCTION func1 RETURN DBMS_XMLDOM.DOMNode IS
l_domdoc DBMS_XMLDOM.DOMDocument;
l_root_node DBMS_XMLDOM.DOMNode;
l_department_element DBMS_XMLDOM.DOMElement;
l_departments_node DBMS_XMLDOM.DOMNode;
l_name_text DBMS_XMLDOM.DOMText;
l_name_textnode DBMS_XMLDOM.DOMNode;
BEGIN
l_domdoc := dbms_xmldom.newDomDocument;
l_root_node := dbms_xmldom.makeNode(l_domdoc);
l_department_element := dbms_xmldom.createElement(l_domdoc, 'Departments' );
l_departments_node := dbms_xmldom.appendChild(l_root_node,dbms_xmldom.makeNode(l_department_element));
l_name_text := dbms_xmldom.createTextNode(l_domdoc, 'Dept1' );
PERFORM dbms_xmldom.appendChild(l_departments_node,dbms_xmldom.makeNode(l_name_text));
l_domdoc := DBMS_XMLDOM.NEWDOMDOCUMENT;
l_root_node := DBMS_XMLDOM.MAKENODE(l_domdoc);
l_department_element := DBMS_XMLDOM.CREATEELEMENT(l_domdoc, 'Departments' );
l_departments_node := DBMS_XMLDOM.APPENDCHILD(l_root_node,DBMS_XMLDOM.MAKENODE(l_department_element));
l_name_text := DBMS_XMLDOM.CREATETEXTNODE(l_domdoc, 'Dept1' );
PERFORM DBMS_XMLDOM.APPENDCHILD(l_departments_node,DBMS_XMLDOM.MAKENODE(l_name_text));
return l_root_node;
END;
```

You can retrieve all the child nodes of the root node by calling `getChildNodes`, and you can determine the number of child nodes using the `getLength` function:
You can retrieve all the child nodes of the root node by calling `GETCHILDNODES`, and you can determine the number of child nodes using the `GETLENGTH` function:

```sql
DECLARE
clist dbms_xmldom.DOMNodeList;
clist DBMS_XMLDOM.DOMNodeList;
len NUMBER;
BEGIN
clist := dbms_xmldom.getChildNodes(func1());
len := dbms_xmldom.getlength(clist);
clist := DBMS_XMLDOM.GETCHILDNODES(func1());
len := DBMS_XMLDOM.GETLENGTH(clist);
dbms_output.put_line('root node num children: ' || to_char(len));
END;
```
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ title: "GETFIRSTCHILD"
The `GETFIRSTCHILD` function retrieves the first child of the particular node. If there is no such node, then this function returns NULL.

```
GETFIRSTCHILD(n DOMNODE) RETURN DOMNODE
GETFIRSTCHILD(n DOMNode) RETURN DOMNode
```

## Parameters

`n`

The DOMNODE whose first child needs to be retrieved.
The `DOMNode` whose first child needs to be retrieved.

## Examples

This example creates a new DOMDocument named `l_domdoc`, and turns it into a DOMNode. Then, it creates a DOMElement named `l_department_element` with the tag name “Departments” and appends this element as a child to the DOMNode. Finally, it outputs the tag name of the first (and in this example, the only) appended child.
This example creates a new `DOMDocument` named `l_domdoc`, and turns it into a `DOMNode`. Then, it creates a `DOMElement` named `l_department_element` with the tag name “Departments” and appends this element as a child to the `DOMNode`. Finally, it outputs the tag name of the first (and in this example, the only) appended child.

```sql
DECLARE
l_domdoc dbms_xmldom.DOMDocument;
l_root_node dbms_xmldom.DOMNode;
l_department_element dbms_xmldom.DOMElement;
l_domdoc DBMS_XMLDOM.DOMDocument;
l_root_node DBMS_XMLDOM.DOMNode;
l_department_element DBMS_XMLDOM.DOMElement;


BEGIN
l_domdoc := dbms_xmldom.NewDOMDocument();
l_root_node := dbms_xmldom.makeNode(l_domdoc);
l_department_element := dbms_xmldom.createElement(l_domdoc, 'Deptartments' );
PERFORM dbms_xmldom.appendChild(l_root_node,dbms_xmldom.makeNode(l_department_element));
DBMS_OUTPUT.PUT_LINE(dbms_xmldom.getNodename(dbms_xmldom.getfirstChild(l_root_node)));
l_domdoc := DBMS_XMLDOM.NEWDOMDOCUMENT();
l_root_node := DBMS_XMLDOM.MAKENODE(l_domdoc);
l_department_element := DBMS_XMLDOM.CREATEELEMENT(l_domdoc, 'Deptartments' );
PERFORM DBMS_XMLDOM.APPENDCHILD(l_root_node,DBMS_XMLDOM.MAKENODE(l_department_element));
DBMS_OUTPUT.PUT_LINE(DBMS_XMLDOM.GETNODENAME(DBMS_XMLDOM.GETFIRSTCHILD(l_root_node)));
END;
```
Loading

0 comments on commit 0bd91bd

Please sign in to comment.