- XML (Extensible Markup Language) Reader/Writer
- XML Quick Facts
- Workbench XML Reader Parameters
- Workbench XML Writer Parameters
- Feature Representation
- Mapping File Reference
- xfMap
- Reading the Input XML Document
- Mapping Rules
- Types of Mapping Rules
- Match and Except Expression
- Specifying Several Match Expressions for One Mapping Rule
- Limiting Mapping Rule Activation with Except Expressions
- Mapping Rule States (activation, execution, suspension, and de-activation)
- Using Force Elements During Mapping Rule Activation and Deactivation
- Search-sets
- Expression Elements (Extract and Literal)
- Expression Sequence
- Feature Mapping Rules
- FME Feature Construction
- Feature Type Element
- Attributes Element
- FME Feature Construction (defining mapping rules under the <feature-content-map> element)
- Attribute Element (handling multiple values)
- Attribute Element (handling optional attributes)
- Attribute Element (sequenced attributes)
- Attribute Element (Nillable Attributes)
- Geometry Element
- Geometry Builder States (activation, execution, suspension, and de-activation)
- Geometry Construction
- Composite Geometry Builders
- Built-in Geometry Builders
- xml-point
- xml-point-xy
- xml-line
- xml-area
- xml-donut
- xml-aggregate
- xml-box
- xml-text
- xml-path
- xml-arc
- xml-arc-by-center-point
- xml-elliptical-arc
- xml-circle
- xml-polygon
- xml-face
- xml-composite-surface
- xml-triangulated-surface
- xml-enclosed-surface
- xml-composite-solid
- xml-multi-point
- xml-multi-curve
- xml-multi-area
- xml-multi-text
- xml-multi-surface
- xml-multi-solid
- xml-null
- xml-reverse-geometry
- fme-geometry
- Mapping Segmented Geometric Information
- Geometry Traits (trait element)
- FME Feature Construction (constructing multiple features at a time)
- Structure Element
- References Element
- Apply References Element
- Group Mapping Rules
- Reference Mapping Rules
- Mapping Rules (Optional Elements)
- More Expression Elements
- FME Schema Features
- Reading the Input XML Document
You are here: Popular Formats > XML (Extensible Markup Language) Reader/Writer > xfMap > Expression Elements (Extract and Literal) > Example
Example
The following example illustrates the usage of extract and literal expressions. Consider the following element:
<parent>
<child-A t="A1">A1 text</child-A>
<child-B t="B1">
<gc-Y t="Y1">Y1 text</gc-Y>
<gc-Z t="Z1">Z1 text</gc-Z>
<gc-Z t="Z2">Z2 text</gc-Z>
</child-B>
<child-A t="A2">A2 text</child-A>
<child-B t="B2">
<gc-Z t="Z3">Z3 text</gc-Z>
<gc-Z t="Z4">Z4 text</gc-Z>
</child-B>
</parent>
Let the following mapping rule match the <parent> element above. (Again, we do not specify which elements the mapping rule contains – for the purpose of this example, we only need to know that some of these elements use the expression elements.)
<mapping match="parent">
...
<!-- e1 -->
<extract expr="./child-A"/>
...
<!-- e2 -->
<extract expr="./child-A{1}"/>
...
<!-- e3 -->
<extract expr="./child-A{1}[@t]"/>
...
<!-- e4 -->
<extract expr="./child-B[@t]"/>
...
<!-- e5 -->
<extract expr="./child-B/gc-Y"/>
...
<!-- e6 -->
<extract expr="./child-B/gc-Y[@t]"/>
...
<!-- e7 -->
<extract expr="./child-B{2}/gc-Z{2}[@t]"/>
...
<!-- e8 -->
<extract expr="./child-A{2}"/>
...
<!-- e9 -->
<extract expr="./child-B{2}[@t]"/>
...
<!-- l -->
<literal expr="this is literal data"/>
</mapping
Then:
e1 extracts A1 text.
e2 extracts A1 text.
e3 extracts A1.
e4 extracts B1.
e5 extracts Y1 text.
e6 extracts Y1.
e7 extracts Z4.
e8 extracts A2 text.
e9 extracts B2.
l has the literal value this is literal data.