Skip to content

Commit f54b85c

Browse files
authored
Merge pull request #18 from burnalting/issue17
Document parse-uri xslt function and extractFromUri dashboard expressions
2 parents 10c7e66 + 8c01ac1 commit f54b85c

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

user-guide/dashboards/queries.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,33 @@ Or all data for the previous year:
8787

8888
Or this year so far:
8989

90-
`greater than year()`
90+
`greater than year()`
91+
92+
## URI Fields
93+
Fields containing a Uniform Resource Identifier (URI) in string form can queried to extract the URI's individual components of `authority`, `fragment`, `host`, `path`, `port`, `query`, `scheme`, `schemeSpecificPart` and `userInfo`. See either [RFC 2306: Uniform Resource Identifiers (URI): Generic Syntax](http://www.ietf.org/rfc/rfc2396.txt) or Java's java.net.URI Class for details regarding the components. If any component is not present within the passed URI, then an empty string is returned.
94+
95+
The extraction functions are
96+
97+
* extractAuthorityFromUri\(\) - extract the Authority component
98+
* extractFragmentFromUri\(\) - extract the Fragment component
99+
* extractHostFromUri\(\) - extract the Host component
100+
* extractPathFromUri\(\) - extract the Path component
101+
* extractPortFromUri\(\) - extract the Port component
102+
* extractQueryFromUri\(\) - extract the Query component
103+
* extractSchemeFromUri\(\) - extract the Scheme component
104+
* extractSchemeSpecificPartFromUri\(\) - extract the Scheme specific part component
105+
* extractUserInfoFromUri\(\) - extract the UserInfo component
106+
107+
If the URI is `http://foo:[email protected]:8080/very/long/path.html?p1=v1&p2=v2#more-details` the table below displays the extracted components
108+
109+
Expression | Extraction
110+
--- | ---
111+
extractAuthorityFromUri(${URI}) | foo:bar@w1.superman.com:8080
112+
extractFragmentFromUri(${URI}) | more-details
113+
extractHostFromUri(${URI}) | w1.superman.com
114+
extractPathFromUri(${URI}) | /very/long/path.html
115+
extractPortFromUri(${URI}) | 8080
116+
extractQueryFromUri(${URI}) | p1=v1&p2=v2
117+
extractSchemeFromUri(${URI}) | http
118+
extractSchemeSpecificPartFromUri(${URI}) | //foo:bar@w1.superman.com:8080/very/long/path.html?p1=v1&p2=v2
119+
extractUserInfoFromUri(${URI}) | foo:bar

user-guide/pipelines/xslt/xslt-functions.md

+37
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The following functions are available to aid your translation:
4040
* `lookup(String map, String key, String time, Boolean ignoreWarnings)` - Look up a reference data map using a specified time, e.g. the event time, and ignore any warnings generated by a failed lookup
4141
* `meta(String key)` - Lookup a meta data value for the current stream using the specified key. The key can be `Feed`, `StreamType`, `CreatedTime`, `EffectiveTime`, `Pipeline` or any other attribute supplied when the stream was sent to Stroom, e.g. meta('System').
4242
* `numeric-ip(String ipAddress)` - Convert an IP address to a numeric representation for range comparison
43+
* `parse-uri(String URI)` - Returns an XML structure of the URI providing `authority`, `fragment`, `host`, `path`, `port`, `query`, `scheme`, `schemeSpecificPart`, and `userInfo` components if present.
4344
* `random()` - Get a system generated random number between 0 and 1.
4445
* `search-id()` - Get the id of the batch search when a pipeline is processing as part of a batch search
4546
* `stream-id()` - Get the id of the current input stream that is being processed
@@ -159,3 +160,39 @@ An example of how to count records is shown below:
159160
<xsl:attribute name="Value" select="$count" />
160161
</data>
161162
```
163+
164+
## `parse-uri()`
165+
The parse-uri() function takes a Uniform Resource Identifier (URI) in string form and returns an XML node with a namespace of `uri` containing the URI's individual components of `authority`, `fragment`, `host`, `path`, `port`, `query`, `scheme`, `schemeSpecificPart` and `userInfo`. See either [RFC 2306: Uniform Resource Identifiers (URI): Generic Syntax](http://www.ietf.org/rfc/rfc2396.txt) or Java's java.net.URI Class for details regarding the components.
166+
167+
The following xml
168+
169+
```xml
170+
<!-- Display and parse the URI contained within the text of the rURI element -->
171+
<xsl:variable name="u" select="s:parseUri(rURI)" />
172+
173+
<URI>
174+
<xsl:value-of select="rURI" />
175+
</URI>
176+
<URIDetail>
177+
<xsl:copy-of select="$v"/>
178+
</URIDetail>
179+
```
180+
given the rURI text contains
181+
```
182+
http://foo:[email protected]:8080/very/long/path.html?p1=v1&amp;p2=v2#more-details
183+
```
184+
would provide
185+
```xml
186+
<URL>http://foo:[email protected]:8080/very/long/path.html?p1=v1&amp;p2=v2#more-details</URL>
187+
<URIDetail>
188+
<authority xmlns="uri">foo:[email protected]:8080</authority>
189+
<fragment xmlns="uri">more-details</fragment>
190+
<host xmlns="uri">w1.superman.com</host>
191+
<path xmlns="uri">/very/long/path.html</path>
192+
<port xmlns="uri">8080</port>
193+
<query xmlns="uri">p1=v1&amp;p2=v2</query>
194+
<scheme xmlns="uri">http</scheme>
195+
<schemeSpecificPart xmlns="uri">//foo:[email protected]:8080/very/long/path.html?p1=v1&amp;p2=v2</schemeSpecificPart>
196+
<userInfo xmlns="uri">foo:bar</userInfo>
197+
</URIDetail>
198+
```

0 commit comments

Comments
 (0)