p:namespace-delete (3.1) 

Deletes namespaces from a document.

Summary

<p:declare-step type="p:namespace-delete">
  <input port="source" primary="true" content-types="xml html" sequence="false"/>
  <output port="result" primary="true" content-types="xml html" sequence="false"/>
  <option name="prefixes" as="xs:string" required="true"/>
</p:declare-step>

The p:namespace-delete step deletes namespaces, for which the prefixes are listed in the prefixes option, from elements and attributes in the document appearing on its source. The resulting document appears on the result port.

Ports:

Port

Type

Primary?

Content types

Seq?

Description

source

input

true

xml html

false

The document to delete the namespaces from.

result

output

true

xml html

false

The resulting document

Options:

Name

Type

Req?

Description

prefixes

xs:string

true

A whitespace-separated list of namespace-prefixes. These prefixes must be defined in your pipeline. The namespaces associated with the prefixes are removed.

Description

The p:namespace-delete step takes the value of its prefixes option, which must be a whitespace separated list of namespace-prefixes, and finds out which namespaces are associated with these prefixes. These namespace prefixes must be defined in the pipeline. It then uses this list to delete these namespaces from elements and attributes in the document appearing on the source port. Elements and attributes that were in one of these namespaces are now in the no-namespace. The resulting document appears on the result port.

Note that matching is done on namespace name, not on namespace-prefix. This means that the prefix as used in the prefixes option might be different from the one used in the document to delete the namespace from. See the Basic usage with different namespace-prefixes example.

Examples

Basic usage

The following example deletes the #myconfig namespace, associated with the prefix con, from the source document.

Source document:

<config xmlns:con="#myconfig" con:status="special">
   <con:thing>button</con:thing>
</config>

Pipeline document:

<p:declare-step xmlns:con="#myconfig" xmlns:p="http://www.w3.org/ns/xproc" version="3.0">

  <p:input port="source"/>
  <p:output port="result"/>

  <p:namespace-delete prefixes="con"/>

</p:declare-step>

Result document:

<config status="special">
   <thing>button</thing>
</config>

Basic usage with different namespace-prefixes

The following example again deletes the #myconfig namespace. However, the namespace-prefix used in the pipeline is different from the one used in the source document.

Source document:

<config xmlns:con="#myconfig" con:status="special">
   <con:thing>button</con:thing>
</config>

Pipeline document:

<p:declare-step xmlns:ns1="#myconfig" xmlns:p="http://www.w3.org/ns/xproc" version="3.0">

  <p:input port="source"/>
  <p:output port="result"/>

  <p:namespace-delete prefixes="ns1"/>

</p:declare-step>

Result document:

<config status="special">
   <thing>button</thing>
</config>

Additional details

  • p:namespace-delete preserves all document-properties of the document(s) appearing on its source port.

Errors raised

Error code

Description

XC0108

It is a dynamic error if any prefix is not in-scope at the point where the p:namespace-delete occurs.

XC0109

It is a dynamic error if a namespace is to be removed from an attribute and the element already has an attribute with the resulting name. For instance, removing the namespace with the ns1 prefix will raise this error when applied to <something ns1:status="ok" status="bad"/>.

Reference information

This description of the p:namespace-delete step is for XProc version: 3.1. This is a required step (an XProc 3.1 processor must support this).

The formal specification for the p:namespace-delete step can be found here.

The p:namespace-delete step is part of categories:

The p:namespace-delete step is also present in version: 3.0.