|
|
ooxml:custom-xml(
|
|
$content as element(),
|
|
$tag as xs:string
|
| ) as element(w:customXml)? |
|
 |
Summary:
This function tags $content with
w:customXml and sets the @element value
to $tag.
|
Parameters:
$content
:
The content
element.
|
$tag
:
The name of the
custom XML tag.
|
|
Usage Notes:
The $content parameter must either be an element of type
paragraph (w:p) , run (w:r), field (w:fldSimple,w:fldChar),
hyperlink (w:hyperlink), custom xml (w:customXml), structured
document tag (w:sdt), table (w:tbl), cel (w:tc), or row (w:tr).
If it is not one of these types, the function
returns the empty sequence.
|
Example:
xquery version "1.0-ml";
import module namespace ooxml= "http://marklogic.com/openxml"
at "MarkLogic/openxml/word-processing-ml.xqy";
let $para:=
<w:p xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:r><w:t>This is my paragraph.</w:t></w:r>
</w:p>
let $tag := "ABCD"
return ooxml:custom-xml($para,$tag)
=>
<w:customXml w:element="ABCD"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:p><w:r><w:t>This is my paragraph.</w:t></w:r></w:p>
</w:customXml>
|
|
|
|
ooxml:custom-xml-highlight(
|
|
$nodes as node()*,
|
|
$highlight-term as cts:query,
|
|
$tag-name as xs:string,
|
|
[$attributes as xs:string*],
|
|
[$values as xs:string*]
|
| ) as node()* |
|
 |
Summary:
This function highlights $hightlight-term in $nodes
by applying <w:customXml w:element={$tag-name}>
to the term. It searches for term within
w:t elements within a w:r
(runs), wrapping a customXml element around the element
the element containing the highlighted match.
|
Parameters:
$nodes
:
The paragraph(s) from
which to search for the highlighted terms.
|
$highlight-term
:
The
cts:query used to find the
highlight term.
|
$tag-name
:
The
name used for the w:customXml w:element
attribute value.
|
$attributes
(optional):
A list of attributes to be added to the
w:customXml properties.
|
$values
(optional):
The values corresponding to the $attributes.
|
|
Usage Notes:
If you specify the $attributes and $values parameters, the length
of the list for each parameter must be the same, otherwise an
exception is thrown.
|
Example:
xquery version "1.0-ml";
import module namespace ooxml= "http://marklogic.com/openxml"
at "MarkLogic/openxml/word-processing-ml.xqy";
declare namespace w=
"http://schemas.openxmlformats.org/wordprocessingml/2006/main";
let $wp := <w:p><w:r><w:t>THIS IS A TEST!</w:t></w:r></w:p>
let $wordquery := cts:word-query("TEST")
return ooxml:custom-xml-highlight($wp,$wordquery,"MYTAG")
=>
<w:p xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:r>
<w:t xml:space="preserve">THIS IS A </w:t>
</w:r>
<w:customXml w:element="MYTAG">
<w:r>
<w:t>TEST</w:t>
</w:r>
</w:customXml>
<w:r>
<w:t xml:space="preserve">!</w:t>
</w:r>
</w:p>
|
Example:
xquery version "1.0-ml";
import module namespace ooxml= "http://marklogic.com/openxml"
at "MarkLogic/openxml/word-processing-ml.xqy";
declare namespace w=
"http://schemas.openxmlformats.org/wordprocessingml/2006/main";
let $wp := <w:p><w:r><w:t>THIS IS A TEST!</w:t></w:r></w:p>
let $wordquery := cts:word-query("TEST")
let $attributes := ("author","id")
let $values := ("oslo","1")
return ooxml:custom-xml-highlight($wp,$wordquery,"MYTAG", $attributes, $values)
=>
<w:p xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:r>
<w:t xml:space="preserve">THIS IS A </w:t>
</w:r>
<w:customXml w:element="MYTAG">
<w:customXmlPr>
<w:attr w:name="author" w:val="oslo"/>
<w:attr w:name="id" w:val="1"/>
</w:customXmlPr>
<w:r>
<w:t>TEST</w:t>
</w:r>
</w:customXml>
<w:r>
<w:t xml:space="preserve">!</w:t>
</w:r>
</w:p>
|
|
|
|
ooxml:replace-paragraph-styles(
|
|
$block as element(),
|
|
$wpProps as element(w:pPr)?
|
| ) as element() |
|
 |
Summary:
This function sets paragraph properties for
paragraphs (w:p) within a
block. If the empty sequence is passed for $wpProps, then
the paragraph properties for the $block are
removed.
|
Parameters:
$block
:
The block containing
the paragraph to be updated.
|
$wpProps
:
The paragraph
properties, as a w:pPr element, to be applied within the
paragraph block.
|
|
Usage Notes:
If $block already has styles applied, these styles are replaced
by the new style parameters. If the empty sequence is
passed for $wpProps, the paragraph properties for the
$block are removed. If there are no properties currently
defined for the paragraph, the $wpProps are applied.
Note that this function does not validate that the
w:pPr element passed in is valid, so make sure the
element you pass in is valid WordProcessingML markup. If you pass
in an invalid element, it could result in a document that
cannot be opened in Microsoft Word.
|
Example:
xquery version "1.0-ml";
import module namespace ooxml= "http://marklogic.com/openxml"
at "MarkLogic/openxml/word-processing-ml.xqy";
declare namespace w=
"http://schemas.openxmlformats.org/wordprocessingml/2006/main";
let $wp1 :=
<w:p>
<w:r><w:t>THIS IS A TEST!</w:t></w:r>
</w:p>
let $pPr := <w:pPr><w:b/></w:pPr>
return ooxml:replace-paragraph-styles($wp1,$pPr)
=>
<w:p xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:pPr>
<w:b/>
</w:pPr>
<w:t>THIS IS A TEST!</w:t>
</w:p>
|
|
|
|
ooxml:replace-style-definition(
|
|
$newstyle as element(w:style),
|
|
$styles as element(w:styles)
|
| ) as element(w:styles) |
|
 |
Summary:
This function replaces w:style
elements (style definitions) in w:styles
(the styles.xml file from a .docx package).
|
Parameters:
$newstyle
:
The new style
element.
|
$styles
:
The old styles
element (from styles.xml).
|
|
Usage Notes:
If the id for the style $newstyle matches a style definition already
present in $styles, the $newstyle will replace the existing
style.
If the id for the style $newstyle does not exist in $styles, the
$newstyle definition will be appended to the other
definitions in $styles.
Note that it is possible within Microsoft Word to create styles
with names that differ only in their case that have different
style attributes. For example,
you can create two styles: "mystyle" and "MYSTYLE", which
have completely different style definitions.
|
Example:
xquery version "1.0-ml";
import module namespace ooxml= "http://marklogic.com/openxml"
at "MarkLogic/openxml/word-processing-ml.xqy";
let $oldstyle :=
<w:styles
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:style w:type="character" w:customStyle="1" w:styleId="oslo">
<w:name w:val="oslo"/><w:basedOn w:val="Emphasis"/>
<w:uiPriority w:val="1"/><w:qFormat/><w:rsid w:val="005B2E7B"/>
<w:rPr><w:rFonts w:ascii="Bodoni MT Black" w:hAnsi="Bodoni MT Black"/>
<w:b/><w:sz w:val="32"/></w:rPr>
</w:style>
</w:styles>
let $newstyle :=
<w:style
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
w:type="character" w:customStyle="1" w:styleId="oslo">
<w:name w:val="oslo"/><w:basedOn w:val="Emphasis"/>
<w:uiPriority w:val="1"/><w:qFormat/><w:rsid w:val="005B2E7B"/>
<w:rPr><w:rFonts w:ascii="Courier New" w:hAnsi="Courier New"/>
<w:b/><w:sz w:val="32"/></w:rPr>
</w:style>
return
ooxml:replace-style-definition($newstyle, $oldstyle)
=>
<w:styles
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:style w:type="character" w:customStyle="1" w:styleId="oslo">
<w:name w:val="oslo"/><w:basedOn w:val="Emphasis"/>
<w:uiPriority w:val="1"/><w:qFormat/><w:rsid w:val="005B2E7B"/>
<w:rPr><w:rFonts w:ascii="Courier New" w:hAnsi="Courier New"/>
<w:b/>
<w:sz w:val="32"/>
</w:rPr>
</w:style>
</w:styles>
|
|
|