SQLEncodeElement
Guide to Encoding / Decoding XML for storage in a database
Release Notes
attachGoldenThread
cast
copy
cutGoldenThread
cwu
delete
dpml
dump
entrypoint
exists
expire
fls
guid
hotRestart
HTTPCookie
HTTPRedirect
isUnix
locationToXPath
lock/unlock
log
loglevel
luceneIndex
luceneSearch
mapper
mapper-export
md5
mls
netkernel:*
new
Orchextra
org.ten60.util.aspell
org.ten60.util.image.SVG2PNG
org.ten60.util.image.Text2PNG
org.ten60.util.image.xchart
plainTextToXHTML
regex
relativizeURI
requestWithArgs
resolveURI
serialize
sleep
sqlBatch
sqlBooleanQuery
SQLEncodeElement
SQLEscapeXML
sqlQuery
sqlUpdate
stm
stopWatch
StringToCanonicalString
throw
toRelaxNG
trace
validateDTD
validateRNG
validateSchematron
validateXSD
xacml
xform
XHREFlinker
XHTMLredirect
XHTMLTidy
xinclude
xmltidy
xpatheval
xpur
xquery
xrl
xsign
xslfo-fop
xslfo-fop
xslt
xverify
License
Change History
NetKernel History
Acknowledgements

SQLEncodeElement/SQLDecodeElement

Accessor to Encode/Decode XML to/from a form suitable for storing in an RDBMS

Module

urn:org:ten60:netkernel:mod:db

Definition

Format

<instr>
  <type>SQLEncodeElement</type>
  <operand>var:source</operand>
  <operator>
    <xpath>/path/to/element</xpath>
  </operator>
  <target>var:encoded</target>
</instr>

Syntax

ElementRulesDescription
typeMandatory SQLEncodeElement/SQLDecodeElement
operandMandatory the URI of the XML resources
targetMandatory Fragment OKtarget resource

It is often useful to store an XML fragment in a relational database text field.

The SQLEncodeElement/SQLDecodeElement accessor encode/decodes XML to/from a form suitable for storage in a text field of an RDBMS.

Encoding/Decoding is applied to one or multiple elements by specifying the canonical XPath target in the operator.

SQLEncodeElement

SQLEncodeElement serializes an XML fragment located by the canonical XPATH specified in the operator. The element, it's text and all it's child nodes are serialized into escaped text. The elements content becomes the serialized text. All child elements are removed. SQLEncodeElement serializes and collapses to escaped text an XML fragment. The element's text is suitable for storing in a RDBMS text field.

Example

For a source document var:source

<root>
  <a>
    <b>text</b>
  </a>
</root>

Element /root/a is encoded with...

<instr>
  <type>SQLEncodeElement</type>
  <operand>var:source</operand>
  <operator>
    <xpath>/root/a</xpath>
  </operator>
  <target>var:encoded</target>
</instr>

Producing the encoded document...

<root>
  <a> &amp;lt;a&amp;gt; &amp;lt;b&amp;gt;text&amp;lt;/b&amp;gt; &amp;lt;/a&amp;gt; </a>
</root>

SQLDecodeElement

SQLDecodeElement parses a text element and replaces a text element located by the canonical XPATH specified in the operator. The element's text is parsed to an XML fragment. The fragment replaces the text element. SQLDecodeElement inflates an escaped text XML fragment.

Example

The encoded document above is decoded with

<instr>
  <type>SQLDecodeElement</type>
  <operand>var:encoded</operand>
  <operator>
    <xpath>/root/a</xpath>
  </operator>
  <target>var:decoded</target>
</instr>

Producing the original

<root>
  <a>
    <b>text</b>
  </a>
</root>

1060® NetKernelTM Documentation
(C) 2003-2004 1060 Research Limited

Send Feedback

© 2003,2004, 1060® Research Limited
1060 registered trademark, NetKernel trademark of 1060 Research Limited