PMC Bank case: Govt may soon monetise bank collateral to pay off depositors, says report
The Finance Ministry and the Reserve Bank of India are waiting for a formal nod to begin the process.
The government might soon start monetising the Punjab and Maharashtra Cooperative (PMC) Bank's collateral to pay off depositors, sources told CNBC-TV18.
Government sources told CNBC-TV18 that initial investigation in the Punjab and Maharashtra Cooperative (PMC) Bank case indicates that the lender has enough collateral to pay off depositors. They said the government is hopeful that deposits in PMC Bank are safe.
Sufficient collateral is available with the bank, both in the form of land and property, the sources added.
The Finance Ministry and the Reserve Bank of India are waiting for a formal nod to begin the process.
In a huge relief to its depositors, the Reserve Bank of India (RBI) on November 5 increased the withdrawal limit for customers of PMC Bank to Rs 50,000. The move is expected to allow 78 percent of the lender's depositors to withdraw their entire account balance.
Read | PMC Bank: RBI increases deposit withdrawal limit to Rs 50,000, reopens ATMs
The central bank also announced that customers would be able to make withdrawals within the relaxed limit of Rs 50,000 from the bank's own ATMs.Special Thursday Expiry on 10th 7th Nov
Early Closure to The Great Diwali Discount. Last Chance to get Moneycontrol PRO for a year @ Rs. 289/- only
Coupon code: DIWALI


If your using an Apple Mac replace the CTRL key with ⌘ key.
General
- Keyboard help
- ?(Shift+/)
- Switch panel focus
- CTRL+F6
- Undo
- CTRL+Z
- Redo
- CTRL+SHIFT+Z
Canvas
- Zoom in
- CTRL+
- Zoom out
- CTRL–
- Zoom to fit
- CTRL+0
- Zoom to 100%
- CTRL+1
- Pan
- Spacebar+ mouse click and drag
Copy and Paste
- Cut
- CTRL+X
- Copy
- CTRL+C
- Paste
- CTRL+V
Saving
- Save
- CTRL+S
- Save As
- CTRL+SHIFT+S


Original (uncompressed)
Size: 168.1KB (optimized with pngout)
Color: 99; Alpha: 99
Size: 211.4KB (155.7KB gzipped = 93%)
Color: 90; Alpha: 90
Size: 84.7KB (61.4KB gzipped = 37%)
Color: 85; Alpha: 60 (default)
Size: 46.8KB (33.7KB gzipped = 20%)
Color: 60; Alpha: 30
Size: 29.1KB (20.7KB gzipped = 12%)
Color: 20; Alpha: 20
Size: 17.0KB (11.6KB gzipped = 7%)


Copyright © 2006,{{CURRENTYEAR}} The Apache Software Foundation. Licensed under
Apache License 2.0.
Apache, the Apache feather logo and OpenJPA are trademarks of The Apache Software Foundation.
Other names may be trademarks of their respective owners.


EARTH GIRLS ARE EASY A film review by Randy Parker Copyright 1996 Randy Parker
RATING: **1/2 (out of ****)
(Review written in 1989)
EARTH GIRLS ARE EASY gives new meaning to the phrase, "leave your brain at the door."
The movie arose from the twisted mind of July Brown, the singer and video star who's responsible for such classic tunes as "The Homecoming Queen Has a Gun" and "I Like My Men Big and Stupid." Brown co-wrote EARTH GIRLS ARE EASY, which takes its name from one of her songs.
Geena Davis stars as a manicurist from the Valley who catches her fiance in bed with another woman. The next day as she's sulking and sunbathing, a space ship inhabited by three furry and sex-starved aliens crash lands in her swimming pool. The aliens, who look kind of like teddy bears, quickly learn English by watching television--isn't that original? Davis initially panics in reaction to her unusual house-guests, but then she comes to her senses and takes them to the "Curl Up & Dye" beauty salon for electrolysis. With their fur removed, we can finally recognize the three aliens as Jeff Goldblum and comedians Jim Carrey and Damon Wayans. The movie depicts their fish-out-of-water misadventures, which include an interplanetary love story between Goldblum and Davis.
EARTH GIRLS ARE EASY is consistently entertaining and engaging. Director Julian Temple, who's best known for rock videos and the film ABSOLUTE BEGINNERS, has created a colorful and fast-moving film. Geena Davis' talents are well suited to her weird and eccentric, yet sympathetic, character. July Brown is extremely appealing in her supporting role as Davis' air-headed, fun-loving, and boy-crazy boss; she's especially hilarious in a musical scene at the beach in which she extolls the virtues of being a dizzy blonde. And Carrey, Wayans, and Goldblum make the most of their one-dimensional roles.
Unfortunately, EARTH GIRLS ARE EASY is too much like a TV sitcom. The movie's slapstick comedy is reminiscent of shows like "Laverne & Shirley." Like most TV sitcoms, EARTH GIRLS ARE EASY is formulaic and doesn't contain an ounce of originality. But even so, the movie does provide a few moments of inspired comedy, such as its satirical barbs at valley girls. Most of the time, however, EARTH GIRLS ARE EASY seems like nothing more than one long July Brown video. The movie is full of musical dance numbers which don't advance the story.
So while EARTH GIRLS ARE EASY is perfect if you're looking for some harmless and disposable entertainment, it won't give you much food for thought. By the end of the closing credits, EARTH GIRLS ARE EASY will have already slipped from memory.
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


Analyze Results¶
This modules contains methods for analyzing the results produced by the trained estimators and benchmarking their performance.
analyze_results¶
-
class
mlaut.analyze_results.analyze_results.
AnalyseResults
(hdf5_output_io, hdf5_input_io, input_h5_original_datasets_group, output_h5_predictions_group, split_datasets_group='split_dts_idx', run_times_group='/run_times', train_idx='train_idx', test_idx='test_idx')[source]¶ Bases:
object
Analyze results of machine learning experiments.
Parameters: - hdf5_input_io (
FilesIO()
) – Instance ofFilesIO()
class. - hdf5_input_io – Instance of
FilesIO()
class. - input_h5_original_datasets_group (string) – location in HDF5 database where the original datasets are stored.
- output_h5_predictions_group (string) – location in HDF5 where the prediction of the estimators will be saved.
- split_datasets_group (string) – location in HDF5 database where the test/train splits are saved.
- run_times_group (string) – location where the run times are saved in the HDF5 database.
- train_idx (string) – name of group where the train split index will be stored.
- test_idx (string) – name of group where the test split index will be stored.
-
average_and_std_error
(scores_dict)[source]¶ Calculates simple average and standard error.
Parameters: scores_dict (dictionary) – Dictionary with estimators (keys) and corresponding prediction accuracies on different datasets. Returns: pandas DataFrame
-
average_training_time
(estimators)[source]¶ Average training time for each estimator.
Parameters: - estimators (mlaut_estimator array) – Estimator objects.
- exact_match (Boolean) – If True when predictions for all estimators in the estimators array is not available no evaluation is performed on the remaining estimators.
Returns: tuple of pandas DataFrame (avg_training_time, trainig_time_per_dataset)
-
cohens_d
(estimator_dict)[source]¶ Cohen’s d is an effect size used to indicate the standardised difference between two means. The calculation is implemented natively (without the use of third-party libraries). More information can be found here: Cohen’s d.
Parameters: estimator_dict (dictionary) – dictionay with keys names of estimators and values errors achieved by estimators on test datasets. Returns: pandas DataFrame.
-
friedman_test
(observations)[source]¶ The Friedman test is a non-parametric statistical test used to detect differences in treatments across multiple test attempts. The procedure involves ranking each row (or block) together, then considering the values of ranks by columns. Implementation used: scipy.stats.
Parameters: observations (dictionary) – Dictionary with errors on test sets achieved by estimators. Returns: tuple of dictionary, pandas DataFrame.
-
nemenyi
(obeservations)[source]¶ Post-hoc test run if the friedman_test reveals statistical significance. For more information see Nemenyi test. Implementation used scikit-posthocs.
Parameters: observations (dictionary) – Dictionary with errors on test sets achieved by estimators. Returns: pandas DataFrame.
-
prediction_errors
(metric, estimators, exact_match=True)[source]¶ Calculates the average prediction error per estimator as well as the prediction error achieved by each estimator on individual datasets.
Parameters: - metric (mlaut.analyse_results.scores) – Error function.
- estimators (mlaut_estimator array) – Estimator objects.
- exact_match (Boolean) – If True when predictions for all estimators in the estimators array is not available no evaluation is performed on the remaining estimators.
Returns: estimator_avg_error
represents the average error and standard deviation achieved by each estimator.estimator_avg_error_per_dataset
represents the average error and standard deviation achieved by each estimator on each dataset.Return type: estimator_avg_error, estimator_avg_error_per_dataset (pickle of pandas DataFrame)
-
ranks
(estimator_dict, ascending)[source]¶ Calculates the average ranks based on the performance of each estimator on each dataset
Parameters: - estimator_dict (dictionary) – dictionay with keys names of estimators and values errors achieved by estimators on test datasets.
- ascending (boolean) – Rank the values in ascending (True) or descending (False) order
Returns: Returns the mean peformance rank for each estimator
Return type: ranks(DataFrame)
-
ranksum_test
(observations)[source]¶ Non-parametric test for testing consistent differences between pairs of obeservations. The test counts the number of observations that are greater, smaller and equal to the mean http://en.wikipedia.org/wiki/Wilcoxon_rank-sum_test.
Parameters: observations (dictionary) – Dictionary with errors on test sets achieved by estimators. Returns: tuple of pandas DataFrame (Database style and MultiIndex)
-
sign_test
(observations)[source]¶ Non-parametric test for test for consistent differences between pairs of observations. See https://en.wikipedia.org/wiki/Sign_test for details about the test and https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.stats.binom_test.html for details about the scipy implementation.
Parameters: observations (dictionary) – Dictionary with errors on test sets achieved by estimators. Returns: tuple of dataframes (pandas DataFrame (Database style), pivot table)
-
t_test
(observations)[source]¶ Runs t-test on all possible combinations between the estimators.
Parameters: observations (dictionary) – Dictionary with errors on test sets achieved by estimators. Returns: tuple of pandas DataFrame (Database style and MultiIndex)
-
t_test_with_bonferroni_correction
(observations, alpha=0.05)[source]¶ correction used to counteract multiple comparissons https://en.wikipedia.org/wiki/Bonferroni_correction
Parameters: - observations (dictionary) – Dictionary with errors on test sets achieved by estimators.
- alpha (float) – confidence level.
Returns: tuple of pandas DataFrame
-
wilcoxon_test
(observations)[source]¶ http://en.wikipedia.org/wiki/Wilcoxon_signed-rank_test Wilcoxon signed-rank test. Tests whether two related paired samples come from the same distribution. In particular, it tests whether the distribution of the differences x-y is symmetric about zero
Parameters: observations (dictionary) – Dictionary with errors on test sets achieved by estimators. Returns: tuple of pandas DataFrame (Database style and MultiIndex)
- hdf5_input_io (
losses¶
-
class
mlaut.analyze_results.losses.
Losses
(metric, estimators, exact_match)[source]¶ Bases:
object
Calculates prediction losses on test datasets achieved by the trained estimators. When the class is instantiated it creates a dictionary that stores the losses.
Parameters: - metric (mlaut.analyze_results.scores object) – score function that will be used for the estimation. Must be mlaut.analyze_results.scores object.
- estimators (array of mlaut estimators) – Array of estimators on which the results will be compared.
- exact_match (Boolean) – If True when predictions for all estimators in the estimators array is not available no evaluation is performed on the remaining estimators.
-
evaluate
(predictions, true_labels, dataset_name)[source]¶ Calculates the loss metrics on the test sets.
Parameters: - predictions (2d numpy array) – Predictions of trained estimators in the form [estimator_name, [predictions]]
- true_labels (numpy array) – true labels of test dataset.
- dataset_name (string) – Name of the dataset.
-
get_losses
()[source]¶ When the Losses class is instantiated a dictionary that holds all losses is created and appended every time the evaluate() method is run. This method returns this dictionary with the losses.
Returns: errors_per_estimator (dictionary), errors_per_dataset_per_estimator (dictionary), errors_per_dataset_per_estimator_df (pandas DataFrame) Return type: Returns dictionaries with the errors achieved by each estimator and errors achieved by each estimator on each of the datasets. errors_per_dataset_per_estimator
anderrors_per_dataset_per_estimator_df
return the same results but the first object is a dictionary and the second one a pandas DataFrame.errors_per_dataset_per_estimator
anderrors_per_dataset_per_estimator_df
contain both the mean error and deviation.
scores¶
-
class
mlaut.analyze_results.scores.
ScoreAccuracy
(round_predictions=True)[source]¶ Bases:
mlaut.analyze_results.scores.MLAUTScore
Calculates the accuracy between the true and predicted lables.
Parameters: round_predictions (Boolean) – Should the predictions be rounded before claculating the accuracy score. This is useful when the accuracy score is used on outputs produced by regressors.
-
class
mlaut.analyze_results.scores.
ScoreMSE
[source]¶ Bases:
mlaut.analyze_results.scores.MLAUTScore
Calculates the mean squared error between the true and predicted lables.
-
class
mlaut.analyze_results.scores.
ScorePrecision
(average='micro')[source]¶ Bases:
mlaut.analyze_results.scores.MLAUTScore
Calculates precision score of classifier.
Parameters: average (string) – Averaging to be performated on the data. Possible parameters as per sklearn documentation. Returns: precision score Return type: float
-
class
mlaut.analyze_results.scores.
ScoreRecall
(average='micro')[source]¶ Bases:
mlaut.analyze_results.scores.MLAUTScore
Calculates recall score of classifier.
Parameters: average (string) – Averaging to be performated on the data. Possible parameters as per sklearn documentation.
Returns: precision score Return type: float


JavaScript is disabled on your browser.
Overview
Package
Class
Tree
Deprecated
Index
Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes
Hierarchy For All Packages
Package Hierarchies:
com.jwetherell.augmented_reality
,
com.jwetherell.augmented_reality.activity
,
com.jwetherell.augmented_reality.camera
,
com.jwetherell.augmented_reality.common
,
com.jwetherell.augmented_reality.data
,
com.jwetherell.augmented_reality.ui
,
com.jwetherell.augmented_reality.ui.objects
,
com.jwetherell.augmented_reality.widget
Class Hierarchy
java.lang.Object
Activity
com.jwetherell.augmented_reality.activity.
SensorsActivity
com.jwetherell.augmented_reality.activity.
AugmentedReality
com.jwetherell.augmented_reality.activity.
Demo
com.jwetherell.augmented_reality.data.
ARData
com.jwetherell.augmented_reality.
BuildConfig
com.jwetherell.augmented_reality.common.
Calculator
com.jwetherell.augmented_reality.camera.
CameraCompatibility
com.jwetherell.augmented_reality.camera.
CameraModel
DataSource
com.jwetherell.augmented_reality.data.
NetworkDataSource
com.jwetherell.augmented_reality.data.
BuzzDataSource
com.jwetherell.augmented_reality.data.
GooglePlacesDataSource
com.jwetherell.augmented_reality.data.
TwitterDataSource
com.jwetherell.augmented_reality.data.
WikipediaDataSource
DataSource
com.jwetherell.augmented_reality.data.
LocalDataSource
com.jwetherell.augmented_reality.common.
LowPassFilter
com.jwetherell.augmented_reality.ui.
Marker
(implements java.lang.Comparable<T>)
com.jwetherell.augmented_reality.ui.
IconMarker
com.jwetherell.augmented_reality.common.
Matrix
com.jwetherell.augmented_reality.ui.objects.
PaintableObject
com.jwetherell.augmented_reality.ui.objects.
PaintableBox
com.jwetherell.augmented_reality.ui.objects.
PaintableBoxedText
com.jwetherell.augmented_reality.ui.objects.
PaintableCircle
com.jwetherell.augmented_reality.ui.objects.
PaintableGps
com.jwetherell.augmented_reality.ui.objects.
PaintableIcon
com.jwetherell.augmented_reality.ui.objects.
PaintableLine
com.jwetherell.augmented_reality.ui.objects.
PaintablePoint
com.jwetherell.augmented_reality.ui.objects.
PaintablePosition
com.jwetherell.augmented_reality.ui.objects.
PaintableRadarPoints
com.jwetherell.augmented_reality.ui.objects.
PaintableText
com.jwetherell.augmented_reality.data.
PhysicalLocation
com.jwetherell.augmented_reality.
R
com.jwetherell.augmented_reality.
R.attr
com.jwetherell.augmented_reality.
R.drawable
com.jwetherell.augmented_reality.
R.id
com.jwetherell.augmented_reality.
R.menu
com.jwetherell.augmented_reality.
R.string
com.jwetherell.augmented_reality.ui.
Radar
com.jwetherell.augmented_reality.data.
ScreenPosition
SeekBar
com.jwetherell.augmented_reality.widget.
VerticalSeekBar
SurfaceView
com.jwetherell.augmented_reality.camera.
CameraSurface
TextView
com.jwetherell.augmented_reality.widget.
VerticalTextView
com.jwetherell.augmented_reality.common.
Vector
View
com.jwetherell.augmented_reality.activity.
AugmentedView
Overview
Package
Class
Tree
Deprecated
Index
Help
PREV
NEXT
FRAMES
NO FRAMES
All Classes


An asynchronous wrapper for the official Clash Royale API.
Official API Link https://developer.clashroyale.com
In order to use the official api, you will need a token. This token can be obtained at the Official API website https://developer.clashroyale.com.
Once you register and get the token, you are ready to start.
Install the package:
yarn add @varandas/clash-royale-api
OR
npm i --save @varandas/clash-royale-api
Usage:
// Import the package
const { ClashRoyaleAPI } = require('@varandas/clash-royale-api')
// Initialize the api
const api = new ClashRoyaleAPI('the token you got from the api')
// Use the api to get cards
api.getCards()
.then(cards => {
// Do something with the cards
})
.catch(err => {
// handle errors
})
All api calls are asynchronous and used in the same way as above in the getCards example.
Clans
getClans(params: IClanRequestParams)
- Returns a list of all the available clans.getClanByTag(tag: string)
- Returns details about a specific clan.getClanMembers(tag: string)
- Returns a list of clan members.getClanWarlog(tag: string)
- Returns the war log for a clangetClanCurrentWar(tag: string)
- Retrieve information about clan's current clan wargetClanCurrentRiverRace(tag: string)
- Retrieve information about clan's current river racePlayers
getPlayerByTag(tag: string)
- Get information about a single player by player tag.getPlayerUpcomingChests(tag: string)
- Get list of reward chests that the player will receive next in the game.getPlayerBattleLog(tag: string)
- Get list of recent battle results for a player.Tournaments
getTournaments(params: ITournamentRequestParams)
- Search all tournaments by name.getTournamentByTag(tag: string)
- Get information about a single tournament by a tournament tag.getGlobalTournaments
- List all available global tournaments.Cards
getCards
- Get list of all available cards.Locations
getLocations(params: ILocationRequestParams)
- List all available locations.getLocationById(id: string, params: ILocationFullRequestParams)
- Get information about specific location.getClanRankinsForLocation(id: string, params: ILocationFullRequestParams)
- Get clan rankings for a specific location.getPlayerRankingsForLocation(id: string, params: ILocationFullRequestParams)
- Get player rankings for a specific location.getClanWarRankingsForLocation(id: string, params: ILocationFullRequestParams)
- Get clan rankings for a specific location.IClanRequestParams
/**
* Note:
* Only the name property is required.
*/
export interface IClanRequestParams {
/**
* Search clans by name.
* If name is used as part of search query, it needs to be at least three
* characters long. Name search parameter is interpreted as wild card
* search, so it may appear anywhere in the clan name.
*/
name: string
/**
* Filter by clan location identifier. For list of available locations,
* refer to getLocations operation.
*/
locationId?: number
/**
* Filter by minimum amount of clan members.
*/
minMembers?: number
/**
* Filter by maximum amount of clan members.
*/
maxMembers?: number
/**
* Filter by minimum amount of clan score.
*/
minScore?: number
/**
* Limit the number of items returned in the response.
*/
limit?: number
/**
* Return only items that occur after this marker.
* After marker can be found from the response, inside the 'paging' property.
* Note that only after or before can be specified for a request, not both.
*/
after?: number
/**
* Return only items that occur before this marker.
* Before marker can be found from the response, inside the 'paging' property.
* Note that only after or before can be specified for a request, not both.
*/
before?: number
}
ITournamentRequestParams
/**
* Note:
* Only the name property is required.
*/
export interface ITournamentRequestParams {
/**
* Search tournaments by name.
*/
name: string
/**
* Limit the number of items returned in the response.
*/
limit?: number
/**
* Return only items that occur after this marker.
* After marker can be found from the response, inside the 'paging' property.
* Note that only after or before can be specified for a request, not both.
*/
after?: number
/**
* Return only items that occur before this marker.
* Before marker can be found from the response, inside the 'paging' property.
* Note that only after or before can be specified for a request, not both.
*/
before?: number
}
ILocationRequestParams
export interface ILocationRequestParams {
/**
* Limit the number of items returned in the response.
*/
limit?: number
/**
* Return only items that occur after this marker.
* After marker can be found from the response,
* inside the 'paging' property. Note that only
* after or before can be specified for a request, not both.
*/
after?: number
/**
* Return only items that occur before this marker.
* Before marker can be found from the response,
* inside the 'paging' property. Note that only
* after or before can be specified for a request, not both.
*/
before?: number
}
Logo by Caneco.
This content is not affiliated with, endorsed, sponsored, or specifically approved by Supercell and Supercell is not responsible for it. For more information see Supercell’s Fan Content Policy.
Generated using TypeDoc


DaTiPi Example
A simple date & time picker using plain JavaScript
Select date and time:
Select another date and time:


File Downloads Example
Save a remote file to your local filesystem using the Windows file picker APIs
Save File


This is basic example, with just one HTML template, with no special tags, and a CSS stylesheet.
This is a paragraph with a strong, emphasized link back to the docs.
Oh, and a picture.


The following examples illustrate some basic ways to provide instructions for inputs that have data entry requirements.
Providing simple instructions within labels
Simple instructions can be provided within an input label, for example, including “required” in the label of an input that must be completed:
Name (required):
Providing an example
In some cases, the best instruction is an example of data in the correct format, for example, including<EMAIL_ADDRESS>in the label to show the required email format:
Email (joe@example.com):
Providing detailed instructions
Some inputs require more detailed instructions that are clearly marked and defined, for example, providing detailed password requirements with a section heading and list of requirements:
Password Requirements
- At least 8 characters
- Uppercase and lowercase letters
- At least one number
- At least one special character


The Rewind function. When you return to a bookmark, it is a good idea to rewind a bit so that the text at the bookmark will be read in context. Press the left panning key on the front edge of the machine to rewind, or press the right panning key for fast forward. You can press Rewind or Fast Forward while you are reading.
in-context


#include <GlobalOptimizationConvergenceCriteria.h>
| open3d::registration::GlobalOptimizationOption::GlobalOptimizationOption |
( |
double |
max_correspondence_distance = 0.075 , |
|
|
double |
edge_prune_threshold = 0.25 , |
|
|
double |
preference_loop_closure = 1.0 , |
|
|
int |
reference_node = -1 |
|
) |
| |
|
inline |
| open3d::registration::GlobalOptimizationOption::~GlobalOptimizationOption |
( |
| ) |
|
|
inline |
| double open3d::registration::GlobalOptimizationOption::edge_prune_threshold_ |
According to [Choi et al 2015], line_process weight < edge_prune_threshold_ (0.25) is pruned.
| double open3d::registration::GlobalOptimizationOption::max_correspondence_distance_ |
See reference list in GlobalOptimization.h Identifies which distance value is used for finding neighboring points when making information matrix. According to [Choi et al 2015], this distance is used for determining $mu, a line process weight.
| double open3d::registration::GlobalOptimizationOption::preference_loop_closure_ |
Balancing parameter to decide which one is more reliable: odometry vs loop-closure. [0,1] -> try to unchange odometry edges, [1) -> try to utilize loop-closure. Recommendation: 0.1 for RGBD Odometry, 2.0 for fragment registration
| int open3d::registration::GlobalOptimizationOption::reference_node_ |
The pose of this node is unchanged after optimization.
The documentation for this class was generated from the following file:


This is Purple Cheetah example application. It is not meant to be used for serving front-end content, it main purpose is to be used for building web API applications. Click here to see JSON response.


--- layout: post title: no title date: '2014-12-04T07:30:23+01:00' categories: - Sketches picture_url: https://film-Storyboards.tumblr.com/post/104325737787 ---


Check your email for a booking confirmation We'll save you soon!
© 2019 Ticket For Us. All Rights Reserved.


Here we have a variation on a standard Rosse chart which produces a grouping effect. The property that causes the offset is called segmentsAngleOffset and on one Rose chart (there are two)it is set to -0.15 whilst on the other it is set at 0.15. This "rotates" one Rose chart backwards whilst the other is "rotated" forwards.
Both charts use the grow() animation effect.
This goes in the documents header:  Put this where you want the chart to show up:

This is the code that generates the chart:


Use this form to try things out or simply POST some GeoJSON to /tiles/zoom/x/y.png
to get back a tile.
Some quick notes: this is a rather quick-and-simple example. You must upload
GeoJSON data and it must be in WGS84 (latitude/longitude). This service could
be smarter and handler more formats, but it's not.


Expat is a library, written in C, for parsing XML documents. It's
the underlying XML parser for the open source Mozilla project, Perl's
XML::Parser
, Python's xml.parsers.expat
, and
other open-source XML parsers.
This library is the creation of James Clark, who's also given us groff (an nroff look-alike), Jade (an implementation of ISO's DSSSL stylesheet language for SGML), XP (a Java XML parser package), XT (a Java XSL engine). James was also the technical lead on the XML Working Group at W3C that produced the XML specification.
This is free software, licensed under the MIT/X Consortium license. You may download it from the Expat home page.
The bulk of this document was originally commissioned as an article by XML.com. They graciously allowed Clark Cooper to retain copyright and to distribute it with Expat. This version has been substantially extended to include documentation on features which have been added since the original article was published, and additional information on using the original interface.
Table of Contents
- Overview
- Building and Installing
- Using Expat
- Reference
- Parser Creation Functions
- Parsing Functions
- Handler Setting Functions
- XML_SetStartElementHandler
- XML_SetEndElementHandler
- XML_SetElementHandler
- XML_SetCharacterDataHandler
- XML_SetProcessingInstructionHandler
- XML_SetCommentHandler
- XML_SetStartCdataSectionHandler
- XML_SetEndCdataSectionHandler
- XML_SetCdataSectionHandler
- XML_SetDefaultHandler
- XML_SetDefaultHandlerExpand
- XML_SetExternalEntityRefHandler
- XML_SetExternalEntityRefHandlerArg
- XML_SetSkippedEntityHandler
- XML_SetUnknownEncodingHandler
- XML_SetStartNamespaceDeclHandler
- XML_SetEndNamespaceDeclHandler
- XML_SetNamespaceDeclHandler
- XML_SetXmlDeclHandler
- XML_SetStartDoctypeDeclHandler
- XML_SetEndDoctypeDeclHandler
- XML_SetDoctypeDeclHandler
- XML_SetElementDeclHandler
- XML_SetAttlistDeclHandler
- XML_SetEntityDeclHandler
- XML_SetUnparsedEntityDeclHandler
- XML_SetNotationDeclHandler
- XML_SetNotStandaloneHandler
- Parse Position and Error Reporting Functions
- Billion Laughs Attack Protection
- Miscellaneous Functions
- XML_SetUserData
- XML_GetUserData
- XML_UseParserAsHandlerArg
- XML_SetBase
- XML_GetBase
- XML_GetSpecifiedAttributeCount
- XML_GetIdAttributeIndex
- XML_GetAttributeInfo
- XML_SetEncoding
- XML_SetParamEntityParsing
- XML_SetHashSalt
- XML_UseForeignDTD
- XML_SetReturnNSTriplet
- XML_DefaultCurrent
- XML_ExpatVersion
- XML_ExpatVersionInfo
- XML_GetFeatureList
- XML_FreeContentModel
- XML_MemMalloc
- XML_MemRealloc
- XML_MemFree
Overview
Expat is a stream-oriented parser. You register callback (or handler) functions with the parser and then start feeding it the document. As the parser recognizes parts of the document, it will call the appropriate handler for that part (if you've registered one.) The document is fed to the parser in pieces, so you can start parsing before you have all the document. This also allows you to parse really huge documents that won't fit into memory.
Expat can be intimidating due to the many kinds of handlers and options you can set. But you only need to learn four functions in order to do 90% of what you'll want to do with it:
XML_ParserCreate
- Create a new parser object.
XML_SetElementHandler
- Set handlers for start and end tags.
XML_SetCharacterDataHandler
- Set handler for text.
XML_Parse
- Pass a buffer full of document to the parser
These functions and others are described in the reference part of this document. The reference section also describes in detail the parameters passed to the different types of handlers.
Let's look at a very simple example program that only uses 3 of the
above functions (it doesn't need to set a character handler.) The
program outline.c prints an
element outline, indenting child elements to distinguish them from the
parent element that contains them. The start handler does all the
work. It prints two indenting spaces for every level of ancestor
elements, then it prints the element and attribute
information. Finally it increments the global Depth
variable.
int Depth; void XMLCALL start(void *data, const char *el, const char **attr) { int i; for (i = 0; i < Depth; i++) printf(" "); printf("%s", el); for (i = 0; attr[i]; i += 2) { printf(" %s='%s'", attr[i], attr[i + 1]); } printf("\n"); Depth++; } /* End of start handler */
The end tag simply does the bookkeeping work of decrementing
Depth
.
void XMLCALL end(void *data, const char *el) { Depth--; } /* End of end handler */
Note the XMLCALL
annotation used for the callbacks.
This is used to ensure that the Expat and the callbacks are using the
same calling convention in case the compiler options used for Expat
itself and the client code are different. Expat tries not to care
what the default calling convention is, though it may require that it
be compiled with a default convention of "cdecl" on some platforms.
For code which uses Expat, however, the calling convention is
specified by the XMLCALL
annotation on most platforms;
callbacks should be defined using this annotation.
The XMLCALL
annotation was added in Expat 1.95.7, but
existing working Expat applications don't need to add it (since they
are already using the "cdecl" calling convention, or they wouldn't be
working). The annotation is only needed if the default calling
convention may be something other than "cdecl". To use the annotation
safely with older versions of Expat, you can conditionally define it
after including Expat's header file:
#include <expat.h> #ifndef XMLCALL #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__) #define XMLCALL __cdecl #elif defined(__GNUC__) #define XMLCALL __attribute__((cdecl)) #else #define XMLCALL #endif #endif
After creating the parser, the main program just has the job of shoveling the document to the parser so that it can do its work.
Building and Installing Expat
The Expat distribution comes as a compressed (with GNU gzip) tar file. You may download the latest version from Source Forge. After unpacking this, cd into the directory. Then follow either the Win32 directions or Unix directions below.
Building under Win32
If you're using the GNU compiler under cygwin, follow the Unix
directions in the next section. Otherwise if you have Microsoft's
Developer Studio installed,
you can use CMake to generate a .sln
file, e.g.
cmake -G"Visual Studio 15 2017" -DCMAKE_BUILD_TYPE=RelWithDebInfo .
, and build Expat using msbuild /m expat.sln
after.
Alternatively, you may download the Win32 binary package that contains the "expat.h" include file and a pre-built DLL.
Building under Unix (or GNU)
First you'll need to run the configure shell script in order to configure the Makefiles and headers for your system.
If you're happy with all the defaults that configure picks for you, and you have permission on your system to install into /usr/local, you can install Expat with this sequence of commands:
./configure make make install
There are some options that you can provide to this script, but the
only one we'll mention here is the --prefix
option. You
can find out all the options available by running configure with just
the --help
option.
By default, the configure script sets things up so that the library
gets installed in /usr/local/lib
and the associated
header file in /usr/local/include
. But if you were to
give the option, --prefix=/home/me/mystuff
, then the
library and header would get installed in
/home/me/mystuff/lib
and
/home/me/mystuff/include
respectively.
Configuring Expat Using the Pre-Processor
Expat's feature set can be configured using a small number of
pre-processor definitions. The definition of this symbols does not
affect the set of entry points for Expat, only the behavior of the API
and the definition of character types in the case of
XML_UNICODE_WCHAR_T
. The symbols are:
- XML_DTD
- Include support for using and reporting DTD-based content. If
this is defined, default attribute values from an external DTD subset
are reported and attribute value normalization occurs based on the
type of attributes defined in the external subset. Without
this, Expat has a smaller memory footprint and can be faster, but will
not load external entities or process conditional sections. If defined, makes
the functions
XML_SetBillionLaughsAttackProtectionMaximumAmplification
andXML_SetBillionLaughsAttackProtectionActivationThreshold
available. - XML_NS
- When defined, support for the Namespaces in XML specification is included.
- XML_UNICODE
- When defined, character data reported to the application is
encoded in UTF-16 using wide characters of the type
XML_Char
. This is implied ifXML_UNICODE_WCHAR_T
is defined. - XML_UNICODE_WCHAR_T
- If defined, causes the
XML_Char
character type to be defined using thewchar_t
type; otherwise,unsigned short
is used. Defining this impliesXML_UNICODE
. - XML_LARGE_SIZE
- If defined, causes the
XML_Size
andXML_Index
integer types to be at least 64 bits in size. This is intended to support processing of very large input streams, where the return values ofXML_GetCurrentByteIndex
,XML_GetCurrentLineNumber
andXML_GetCurrentColumnNumber
could overflow. It may not be supported by all compilers, and is turned off by default. - XML_CONTEXT_BYTES
- The number of input bytes of markup context which the parser will
ensure are available for reporting via
XML_GetInputContext
. This is normally set to 1024, and must be set to a positive integer. If this is not defined, the input context will not be available andXML_GetInputContext
will always reportNULL
. Without this, Expat has a smaller memory footprint and can be faster. - XML_STATIC
- On Windows, this should be set if Expat is going to be linked statically with the code that calls it; this is required to get all the right MSVC magic annotations correct. This is ignored on other platforms.
- XML_ATTR_INFO
- If defined, makes the additional function
XML_GetAttributeInfo
available for reporting attribute byte offsets.
Using Expat
Compiling and Linking Against Expat
Unless you installed Expat in a location not expected by your
compiler and linker, all you have to do to use Expat in your programs
is to include the Expat header (#include <expat.h>
)
in your files that make calls to it and to tell the linker that it
needs to link against the Expat library. On Unix systems, this would
usually be done with the -lexpat
argument. Otherwise,
you'll need to tell the compiler where to look for the Expat header
and the linker where to find the Expat library. You may also need to
take steps to tell the operating system where to find this library at
run time.
On a Unix-based system, here's what a Makefile might look like when Expat is installed in a standard location:
CC=cc LDFLAGS= LIBS= -lexpat xmlapp: xmlapp.o $(CC) $(LDFLAGS) -o xmlapp xmlapp.o $(LIBS)
If you installed Expat in, say, /home/me/mystuff
, then
the Makefile would look like this:
CC=cc CFLAGS= -I/home/me/mystuff/include LDFLAGS= LIBS= -L/home/me/mystuff/lib -lexpat xmlapp: xmlapp.o $(CC) $(LDFLAGS) -o xmlapp xmlapp.o $(LIBS)
You'd also have to set the environment variable
LD_LIBRARY_PATH
to /home/me/mystuff/lib
(or
to ${LD_LIBRARY_PATH}:/home/me/mystuff/lib
if
LD_LIBRARY_PATH already has some directories in it) in order to run
your application.
Expat Basics
As we saw in the example in the overview, the first step in parsing
an XML document with Expat is to create a parser object. There are three functions in the Expat API for creating a
parser object. However, only two of these (XML_ParserCreate
and XML_ParserCreateNS
) can be used for
constructing a parser for a top-level document. The object returned
by these functions is an opaque pointer (i.e. "expat.h" declares it as
void *) to data with further internal structure. In order to free the
memory associated with this object you must call XML_ParserFree
. Note that if you have
provided any user data that gets stored in the
parser, then your application is responsible for freeing it prior to
calling XML_ParserFree
.
The objects returned by the parser creation functions are good for parsing only one XML document or external parsed entity. If your application needs to parse many XML documents, then it needs to create a parser object for each one. The best way to deal with this is to create a higher level object that contains all the default initialization you want for your parser objects.
Walking through a document hierarchy with a stream oriented parser will require a good stack mechanism in order to keep track of current context. For instance, to answer the simple question, "What element does this text belong to?" requires a stack, since the parser may have descended into other elements that are children of the current one and has encountered this text on the way out.
The things you're likely to want to keep on a stack are the currently opened element and it's attributes. You push this information onto the stack in the start handler and you pop it off in the end handler.
For some tasks, it is sufficient to just keep information on what the depth of the stack is (or would be if you had one.) The outline program shown above presents one example. Another such task would be skipping over a complete element. When you see the start tag for the element you want to skip, you set a skip flag and record the depth at which the element started. When the end tag handler encounters the same depth, the skipped element has ended and the flag may be cleared. If you follow the convention that the root element starts at 1, then you can use the same variable for skip flag and skip depth.
void init_info(Parseinfo *info) { info->skip = 0; info->depth = 1; /* Other initializations here */ } /* End of init_info */ void XMLCALL rawstart(void *data, const char *el, const char **attr) { Parseinfo *inf = (Parseinfo *) data; if (! inf->skip) { if (should_skip(inf, el, attr)) { inf->skip = inf->depth; } else start(inf, el, attr); /* This does rest of start handling */ } inf->depth++; } /* End of rawstart */ void XMLCALL rawend(void *data, const char *el) { Parseinfo *inf = (Parseinfo *) data; inf->depth--; if (! inf->skip) end(inf, el); /* This does rest of end handling */ if (inf->skip == inf->depth) inf->skip = 0; } /* End rawend */
Notice in the above example the difference in how depth is manipulated in the start and end handlers. The end tag handler should be the mirror image of the start tag handler. This is necessary to properly model containment. Since, in the start tag handler, we incremented depth after the main body of start tag code, then in the end handler, we need to manipulate it before the main body. If we'd decided to increment it first thing in the start handler, then we'd have had to decrement it last thing in the end handler.
Communicating between handlers
In order to be able to pass information between different handlers
without using globals, you'll need to define a data structure to hold
the shared variables. You can then tell Expat (with the XML_SetUserData
function) to pass a
pointer to this structure to the handlers. This is the first
argument received by most handlers. In the reference section, an argument to a callback function is named
userData
and have type void *
if the user
data is passed; it will have the type XML_Parser
if the
parser itself is passed. When the parser is passed, the user data may
be retrieved using XML_GetUserData
.
One common case where multiple calls to a single handler may need
to communicate using an application data structure is the case when
content passed to the character data handler (set by XML_SetCharacterDataHandler
) needs to be accumulated. A
common first-time mistake with any of the event-oriented interfaces to
an XML parser is to expect all the text contained in an element to be
reported by a single call to the character data handler. Expat, like
many other XML parsers, reports such data as a sequence of calls;
there's no way to know when the end of the sequence is reached until a
different callback is made. A buffer referenced by the user data
structure proves both an effective and convenient place to accumulate
character data.
XML Version
Expat is an XML 1.0 parser, and as such never complains based on
the value of the version
pseudo-attribute in the XML
declaration, if present.
If an application needs to check the version number (to support
alternate processing), it should use the XML_SetXmlDeclHandler
function to
set a handler that uses the information in the XML declaration to
determine what to do. This example shows how to check that only a
version number of "1.0"
is accepted:
static int wrong_version; static XML_Parser parser; static void XMLCALL xmldecl_handler(void *userData, const XML_Char *version, const XML_Char *encoding, int standalone) { static const XML_Char Version_1_0[] = {'1', '.', '0', 0}; int i; for (i = 0; i < (sizeof(Version_1_0) / sizeof(Version_1_0[0])); ++i) { if (version[i] != Version_1_0[i]) { wrong_version = 1; /* also clear all other handlers: */ XML_SetCharacterDataHandler(parser, NULL); ... return; } } ... }
Namespace Processing
When the parser is created using the XML_ParserCreateNS
, function, Expat
performs namespace processing. Under namespace processing, Expat
consumes xmlns
and xmlns:...
attributes,
which declare namespaces for the scope of the element in which they
occur. This means that your start handler will not see these
attributes. Your application can still be informed of these
declarations by setting namespace declaration handlers with XML_SetNamespaceDeclHandler
.
Element type and attribute names that belong to a given namespace
are passed to the appropriate handler in expanded form. By default
this expanded form is a concatenation of the namespace URI, the
separator character (which is the 2nd argument to XML_ParserCreateNS
), and the local
name (i.e. the part after the colon). Names with undeclared prefixes
are not well-formed when namespace processing is enabled, and will
trigger an error. Unprefixed attribute names are never expanded,
and unprefixed element names are only expanded when they are in the
scope of a default namespace.
However if XML_SetReturnNSTriplet
has been called with a non-zero
do_nst
parameter, then the expanded form for names with
an explicit prefix is a concatenation of: URI, separator, local name,
separator, prefix.
You can set handlers for the start of a namespace declaration and
for the end of a scope of a declaration with the XML_SetNamespaceDeclHandler
function. The StartNamespaceDeclHandler is called prior to the start
tag handler and the EndNamespaceDeclHandler is called after the
corresponding end tag that ends the namespace's scope. The namespace
start handler gets passed the prefix and URI for the namespace. For a
default namespace declaration (xmlns='...'), the prefix will be
NULL
.
The URI will be NULL
for the case where the default namespace is being
unset. The namespace end handler just gets the prefix for the closing
scope.
These handlers are called for each declaration. So if, for instance, a start tag had three namespace declarations, then the StartNamespaceDeclHandler would be called three times before the start tag handler is called, once for each declaration.
Character Encodings
While XML is based on Unicode, and every XML processor is required to recognized UTF-8 and UTF-16 (1 and 2 byte encodings of Unicode), other encodings may be declared in XML documents or entities. For the main document, an XML declaration may contain an encoding declaration:
<?xml version="1.0" encoding="ISO-8859-2"?>
External parsed entities may begin with a text declaration, which looks like an XML declaration with just an encoding declaration:
<?xml encoding="Big5"?>
With Expat, you may also specify an encoding at the time of creating a parser. This is useful when the encoding information may come from a source outside the document itself (like a higher level protocol.)
There are four built-in encodings in Expat:
- UTF-8
- UTF-16
- ISO-8859-1
- US-ASCII
Anything else discovered in an encoding declaration or in the
protocol encoding specified in the parser constructor, triggers a call
to the UnknownEncodingHandler
. This handler gets passed
the encoding name and a pointer to an XML_Encoding
data
structure. Your handler must fill in this structure and return
XML_STATUS_OK
if it knows how to deal with the
encoding. Otherwise the handler should return
XML_STATUS_ERROR
. The handler also gets passed a pointer
to an optional application data structure that you may indicate when
you set the handler.
Expat places restrictions on character encodings that it can
support by filling in the XML_Encoding
structure.
include file:
- Every ASCII character that can appear in a well-formed XML document must be represented by a single byte, and that byte must correspond to it's ASCII encoding (except for the characters $@\^'{}~)
- Characters must be encoded in 4 bytes or less.
- All characters encoded must have Unicode scalar values less than or equal to 65535 (0xFFFF)This does not apply to the built-in support for UTF-16 and UTF-8
- No character may be encoded by more that one distinct sequence of bytes
XML_Encoding
contains an array of integers that
correspond to the 1st byte of an encoding sequence. If the value in
the array for a byte is zero or positive, then the byte is a single
byte encoding that encodes the Unicode scalar value contained in the
array. A -1 in this array indicates a malformed byte. If the value is
-2, -3, or -4, then the byte is the beginning of a 2, 3, or 4 byte
sequence respectively. Multi-byte sequences are sent to the convert
function pointed at in the XML_Encoding
structure. This
function should return the Unicode scalar value for the sequence or -1
if the sequence is malformed.
One pitfall that novice Expat users are likely to fall into is that although Expat may accept input in various encodings, the strings that it passes to the handlers are always encoded in UTF-8 or UTF-16 (depending on how Expat was compiled). Your application is responsible for any translation of these strings into other encodings.
Handling External Entity References
Expat does not read or parse external entities directly. Note that
any external DTD is a special case of an external entity. If you've
set no ExternalEntityRefHandler
, then external entity
references are silently ignored. Otherwise, it calls your handler with
the information needed to read and parse the external entity.
Your handler isn't actually responsible for parsing the entity, but
it is responsible for creating a subsidiary parser with XML_ExternalEntityParserCreate
that will do the job. This
returns an instance of XML_Parser
that has handlers and
other data structures initialized from the parent parser. You may then
use XML_Parse
or XML_ParseBuffer
calls against this
parser. Since external entities my refer to other external entities,
your handler should be prepared to be called recursively.
Parsing DTDs
In order to parse parameter entities, before starting the parse,
you must call XML_SetParamEntityParsing
with one of the following
arguments:
XML_PARAM_ENTITY_PARSING_NEVER
- Don't parse parameter entities or the external subset
XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE
- Parse parameter entities and the external subset unless
standalone
was set to "yes" in the XML declaration. XML_PARAM_ENTITY_PARSING_ALWAYS
- Always parse parameter entities and the external subset
In order to read an external DTD, you also have to set an external entity reference handler as described above.
Temporarily Stopping Parsing
Expat 1.95.8 introduces a new feature: its now possible to stop parsing temporarily from within a handler function, even if more data has already been passed into the parser. Applications for this include
- Supporting the XInclude specification.
- Delaying further processing until additional information is available from some other source.
- Adjusting processor load as task priorities shift within an application.
- Stopping parsing completely (simply free or reset the parser instead of resuming in the outer parsing loop). This can be useful if an application-domain error is found in the XML being parsed or if the result of the parse is determined not to be useful after all.
To take advantage of this feature, the main parsing loop of an application needs to support this specifically. It cannot be supported with a parsing loop compatible with Expat 1.95.7 or earlier (though existing loops will continue to work without supporting the stop/resume feature).
An application that uses this feature for a single parser will have the rough structure (in pseudo-code):
fd = open_input() p = create_parser() if parse_xml(p, fd) { /* suspended */ int suspended = 1; while (suspended) { do_something_else() if ready_to_resume() { suspended = continue_parsing(p, fd); } } }
An application that may resume any of several parsers based on input (either from the XML being parsed or some other source) will certainly have more interesting control structures.
This C function could be used for the parse_xml
function mentioned in the pseudo-code above:
#define BUFF_SIZE 10240 /* Parse a document from the open file descriptor 'fd' until the parse is complete (the document has been completely parsed, or there's been an error), or the parse is stopped. Return non-zero when the parse is merely suspended. */ int parse_xml(XML_Parser p, int fd) { for (;;) { int last_chunk; int bytes_read; enum XML_Status status; void *buff = XML_GetBuffer(p, BUFF_SIZE); if (buff == NULL) { /* handle error... */ return 0; } bytes_read = read(fd, buff, BUFF_SIZE); if (bytes_read < 0) { /* handle error... */ return 0; } status = XML_ParseBuffer(p, bytes_read, bytes_read == 0); switch (status) { case XML_STATUS_ERROR: /* handle error... */ return 0; case XML_STATUS_SUSPENDED: return 1; } if (bytes_read == 0) return 0; } }
The corresponding continue_parsing
function is
somewhat simpler, since it only need deal with the return code from
XML_ResumeParser
; it can
delegate the input handling to the parse_xml
function:
/* Continue parsing a document which had been suspended. The 'p' and 'fd' arguments are the same as passed to parse_xml(). Return non-zero when the parse is suspended. */ int continue_parsing(XML_Parser p, int fd) { enum XML_Status status = XML_ResumeParser(p); switch (status) { case XML_STATUS_ERROR: /* handle error... */ return 0; case XML_ERROR_NOT_SUSPENDED: /* handle error... */ return 0;. case XML_STATUS_SUSPENDED: return 1; } return parse_xml(p, fd); }
Now that we've seen what a mess the top-level parsing loop can
become, what have we gained? Very simply, we can now use the XML_StopParser
function to stop
parsing, without having to go to great lengths to avoid additional
processing that we're expecting to ignore. As a bonus, we get to stop
parsing temporarily, and come back to it when we're
ready.
To stop parsing from a handler function, use the XML_StopParser
function. This function
takes two arguments; the parser being stopped and a flag indicating
whether the parse can be resumed in the future.
Expat Reference
Parser Creation
XML_ParserCreate
XML_Parser XMLCALL XML_ParserCreate(const XML_Char *encoding);
NULL
, it specifies a
character encoding to use for the document. This overrides the document
encoding declaration. There are four built-in encodings:
- US-ASCII
- UTF-8
- UTF-16
- ISO-8859-1
XML_ParserCreateNS
XML_Parser XMLCALL XML_ParserCreateNS(const XML_Char *encoding, XML_Char sep);
'\xFF'
is not legal in UTF-8, and
'\xFFFF'
is not legal in UTF-16. There is a special case when
sep is the null character '\0'
: the namespace URI and
the local part will be concatenated without any separator - this is intended
to support RDF processors. It is a programming error to use the null separator
with namespace triplets.Note: Expat does not validate namespace URIs (beyond encoding) against RFC 3986 today (and is not required to do so with regard to the XML 1.0 namespaces specification) but it may start doing that in future releases. Before that, an application using Expat must be ready to receive namespace URIs containing non-URI characters.
XML_ParserCreate_MM
XML_Parser XMLCALL XML_ParserCreate_MM(const XML_Char *encoding, const XML_Memory_Handling_Suite *ms, const XML_Char *sep);
typedef struct { void *(XMLCALL *malloc_fcn)(size_t size); void *(XMLCALL *realloc_fcn)(void *ptr, size_t size); void (XMLCALL *free_fcn)(void *ptr); } XML_Memory_Handling_Suite;
Construct a new parser using the suite of memory handling functions
specified in ms
. If ms
is NULL
, then use the
standard set of memory management functions. If sep
is
non-NULL
, then namespace processing is enabled in the created parser
and the character pointed at by sep is used as the separator between
the namespace URI and the local part of the name.
XML_ExternalEntityParserCreate
XML_Parser XMLCALL XML_ExternalEntityParserCreate(XML_Parser p, const XML_Char *context, const XML_Char *encoding);
XML_Parser
object for parsing an external
general entity. Context is the context argument passed in a call to a
ExternalEntityRefHandler. Other state information such as handlers,
user data, namespace processing is inherited from the parser passed as
the 1st argument. So you shouldn't need to call any of the behavior
changing functions on this parser (unless you want it to act
differently than the parent parser).
XML_ParserFree
void XMLCALL XML_ParserFree(XML_Parser p);
XML_ParserReset
XML_Bool XMLCALL XML_ParserReset(XML_Parser p, const XML_Char *encoding);
parser
is
ready to start parsing a new document. All handlers are cleared from
the parser, except for the unknownEncodingHandler. The parser's external
state is re-initialized except for the values of ns and ns_triplets.
This function may not be used on a parser created using XML_ExternalEntityParserCreate
; it will return XML_FALSE
in that case. Returns
XML_TRUE
on success. Your application is responsible for
dealing with any memory associated with user data.
Parsing
To state the obvious: the three parsing functions XML_Parse
,
XML_ParseBuffer
and
XML_GetBuffer
must not be called from within a handler
unless they operate on a separate parser instance, that is, one that
did not call the handler. For example, it is OK to call the parsing
functions from within an XML_ExternalEntityRefHandler
,
if they apply to the parser created by
XML_ExternalEntityParserCreate
.
Note: The len
argument passed to these functions
should be considerably less than the maximum value for an integer,
as it could create an integer overflow situation if the added
lengths of a buffer and the unprocessed portion of the previous buffer
exceed the maximum integer value. Input data at the end of a buffer
will remain unprocessed if it is part of an XML token for which the
end is not part of that buffer.
XML_Parse
enum XML_Status XMLCALL XML_Parse(XML_Parser p, const char *s, int len, int isFinal);
enum XML_Status { XML_STATUS_ERROR = 0, XML_STATUS_OK = 1 };
s
is a buffer
containing part (or perhaps all) of the document. The number of bytes of s
that are part of the document is indicated by len
. This means
that s
doesn't have to be null-terminated. It also means that
if len
is larger than the number of bytes in the block of
memory that s
points at, then a memory fault is likely. The
isFinal
parameter informs the parser that this is the last
piece of the document. Frequently, the last piece is empty (i.e.
len
is zero.)
If a parse error occurred, it returns XML_STATUS_ERROR
.
Otherwise it returns XML_STATUS_OK
value.
XML_ParseBuffer
enum XML_Status XMLCALL XML_ParseBuffer(XML_Parser p, int len, int isFinal);
XML_Parse
,
except in this case Expat provides the buffer. By obtaining the
buffer from Expat with the XML_GetBuffer
function, the application can avoid double
copying of the input.
XML_GetBuffer
void * XMLCALL XML_GetBuffer(XML_Parser p, int len);
len
to read a piece of the document
into. A NULL
value is returned if Expat can't allocate enough memory for
this buffer. A NULL
value may also be returned if len
is zero.
This has to be called prior to every call to
XML_ParseBuffer
. A
typical use would look like this:
for (;;) { int bytes_read; void *buff = XML_GetBuffer(p, BUFF_SIZE); if (buff == NULL) { /* handle error */ } bytes_read = read(docfd, buff, BUFF_SIZE); if (bytes_read < 0) { /* handle error */ } if (! XML_ParseBuffer(p, bytes_read, bytes_read == 0)) { /* handle parse error */ } if (bytes_read == 0) break; }
XML_StopParser
enum XML_Status XMLCALL XML_StopParser(XML_Parser p, XML_Bool resumable);
Stops parsing, causing XML_Parse
or XML_ParseBuffer
to return. Must be called from within a
call-back handler, except when aborting (when resumable
is XML_FALSE
) an already suspended parser. Some
call-backs may still follow because they would otherwise get
lost, including
- the end element handler for empty elements when stopped in the start element handler,
- the end namespace declaration handler when stopped in the end element handler,
- the character data handler when stopped in the character data handler while making multiple call-backs on a contiguous chunk of characters,
and possibly others.
This can be called from most handlers, including DTD related
call-backs, except when parsing an external parameter entity and
resumable
is XML_TRUE
. Returns
XML_STATUS_OK
when successful,
XML_STATUS_ERROR
otherwise. The possible error codes
are:
XML_ERROR_SUSPENDED
- when suspending an already suspended parser.
XML_ERROR_FINISHED
- when the parser has already finished.
XML_ERROR_SUSPEND_PE
- when suspending while parsing an external PE.
Since the stop/resume feature requires application support in the outer parsing loop, it is an error to call this function for a parser not being handled appropriately; see Temporarily Stopping Parsing for more information.
When resumable
is XML_TRUE
then parsing
is suspended, that is, XML_Parse
and XML_ParseBuffer
return XML_STATUS_SUSPENDED
.
Otherwise, parsing is aborted, that is, XML_Parse
and XML_ParseBuffer
return
XML_STATUS_ERROR
with error code
XML_ERROR_ABORTED
.
Note:
This will be applied to the current parser instance only, that is, if
there is a parent parser then it will continue parsing when the
external entity reference handler returns. It is up to the
implementation of that handler to call XML_StopParser
on the parent parser
(recursively), if one wants to stop parsing altogether.
When suspended, parsing can be resumed by calling XML_ResumeParser
.
New in Expat 1.95.8.
XML_ResumeParser
enum XML_Status XMLCALL XML_ResumeParser(XML_Parser p);
Resumes parsing after it has been suspended with XML_StopParser
. Must not be called from
within a handler call-back. Returns same status codes as XML_Parse
or XML_ParseBuffer
. An additional error
code, XML_ERROR_NOT_SUSPENDED
, will be returned if the
parser was not currently suspended.
Note:
This must be called on the most deeply nested child parser instance
first, and on its parent parser only after the child parser has
finished, to be applied recursively until the document entity's parser
is restarted. That is, the parent parser will not resume by itself
and it is up to the application to call XML_ResumeParser
on it at the
appropriate moment.
New in Expat 1.95.8.
XML_GetParsingStatus
void XMLCALL XML_GetParsingStatus(XML_Parser p, XML_ParsingStatus *status);
enum XML_Parsing { XML_INITIALIZED, XML_PARSING, XML_FINISHED, XML_SUSPENDED }; typedef struct { enum XML_Parsing parsing; XML_Bool finalBuffer; } XML_ParsingStatus;
Returns status of parser with respect to being initialized,
parsing, finished, or suspended, and whether the final buffer is being
processed. The status
parameter must not be
NULL
.
New in Expat 1.95.8.
Handler Setting
Although handlers are typically set prior to parsing and left alone, an
application may choose to set or change the handler for a parsing event
while the parse is in progress. For instance, your application may choose
to ignore all text not descended from a para
element. One
way it could do this is to set the character handler when a para start tag
is seen, and unset it for the corresponding end tag.
A handler may be unset by providing a NULL
pointer to the
appropriate handler setter. None of the handler setting functions have
a return value.
Your handlers will be receiving strings in arrays of type
XML_Char
. This type is conditionally defined in expat.h as
either char
, wchar_t
or unsigned short
.
The former implies UTF-8 encoding, the latter two imply UTF-16 encoding.
Note that you'll receive them in this form independent of the original
encoding of the document.
XML_SetStartElementHandler
void XMLCALL XML_SetStartElementHandler(XML_Parser p, XML_StartElementHandler start);
typedef void (XMLCALL *XML_StartElementHandler)(void *userData, const XML_Char *name, const XML_Char **atts);
Set handler for start (and empty) tags. Attributes are passed to the start
handler as a pointer to a vector of char pointers. Each attribute seen in
a start (or empty) tag occupies 2 consecutive places in this vector: the
attribute name followed by the attribute value. These pairs are terminated
by a NULL
pointer.
Note that an empty tag generates a call to both start and end handlers (in that order).
XML_SetEndElementHandler
void XMLCALL XML_SetEndElementHandler(XML_Parser p, XML_EndElementHandler);
typedef void (XMLCALL *XML_EndElementHandler)(void *userData, const XML_Char *name);
Set handler for end (and empty) tags. As noted above, an empty tag generates a call to both start and end handlers.
XML_SetElementHandler
void XMLCALL XML_SetElementHandler(XML_Parser p, XML_StartElementHandler start, XML_EndElementHandler end);
Set handlers for start and end tags with one call.
XML_SetCharacterDataHandler
void XMLCALL XML_SetCharacterDataHandler(XML_Parser p, XML_CharacterDataHandler charhndl)
typedef void (XMLCALL *XML_CharacterDataHandler)(void *userData, const XML_Char *s, int len);
Set a text handler. The string your handler receives
is NOT null-terminated. You have to use the length argument
to deal with the end of the string. A single block of contiguous text
free of markup may still result in a sequence of calls to this handler.
In other words, if you're searching for a pattern in the text, it may
be split across calls to this handler. Note: Setting this handler to NULL
may NOT immediately terminate call-backs if the parser is currently
processing such a single block of contiguous markup-free text, as the parser
will continue calling back until the end of the block is reached.
XML_SetProcessingInstructionHandler
void XMLCALL XML_SetProcessingInstructionHandler(XML_Parser p, XML_ProcessingInstructionHandler proc)
typedef void (XMLCALL *XML_ProcessingInstructionHandler)(void *userData, const XML_Char *target, const XML_Char *data);
Set a handler for processing instructions. The target is the first word in the processing instruction. The data is the rest of the characters in it after skipping all whitespace after the initial word.
XML_SetCommentHandler
void XMLCALL XML_SetCommentHandler(XML_Parser p, XML_CommentHandler cmnt)
typedef void (XMLCALL *XML_CommentHandler)(void *userData, const XML_Char *data);
Set a handler for comments. The data is all text inside the comment delimiters.
XML_SetStartCdataSectionHandler
void XMLCALL XML_SetStartCdataSectionHandler(XML_Parser p, XML_StartCdataSectionHandler start);
typedef void (XMLCALL *XML_StartCdataSectionHandler)(void *userData);
Set a handler that gets called at the beginning of a CDATA section.
XML_SetEndCdataSectionHandler
void XMLCALL XML_SetEndCdataSectionHandler(XML_Parser p, XML_EndCdataSectionHandler end);
typedef void (XMLCALL *XML_EndCdataSectionHandler)(void *userData);
Set a handler that gets called at the end of a CDATA section.
XML_SetCdataSectionHandler
void XMLCALL XML_SetCdataSectionHandler(XML_Parser p, XML_StartCdataSectionHandler start, XML_EndCdataSectionHandler end)
Sets both CDATA section handlers with one call.
XML_SetDefaultHandler
void XMLCALL XML_SetDefaultHandler(XML_Parser p, XML_DefaultHandler hndl)
typedef void (XMLCALL *XML_DefaultHandler)(void *userData, const XML_Char *s, int len);
Sets a handler for any characters in the document which wouldn't otherwise be handled. This includes both data for which no handlers can be set (like some kinds of DTD declarations) and data which could be reported but which currently has no handler set. The characters are passed exactly as they were present in the XML document except that they will be encoded in UTF-8 or UTF-16. Line boundaries are not normalized. Note that a byte order mark character is not passed to the default handler. There are no guarantees about how characters are divided between calls to the default handler: for example, a comment might be split between multiple calls. Setting the handler with this call has the side effect of turning off expansion of references to internally defined general entities. Instead these references are passed to the default handler.
See also XML_DefaultCurrent
.
XML_SetDefaultHandlerExpand
void XMLCALL XML_SetDefaultHandlerExpand(XML_Parser p, XML_DefaultHandler hndl)
typedef void (XMLCALL *XML_DefaultHandler)(void *userData, const XML_Char *s, int len);
This sets a default handler, but doesn't inhibit the expansion of internal entity references. The entity reference will not be passed to the default handler.
See also XML_DefaultCurrent
.
XML_SetExternalEntityRefHandler
void XMLCALL XML_SetExternalEntityRefHandler(XML_Parser p, XML_ExternalEntityRefHandler hndl)
typedef int (XMLCALL *XML_ExternalEntityRefHandler)(XML_Parser p, const XML_Char *context, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId);
Set an external entity reference handler. This handler is also
called for processing an external DTD subset if parameter entity parsing
is in effect. (See
XML_SetParamEntityParsing
.)
The context
parameter specifies the parsing context in
the format expected by the context
argument to XML_ExternalEntityParserCreate
. code
is
valid only until the handler returns, so if the referenced entity is
to be parsed later, it must be copied. context
is NULL
only when the entity is a parameter entity, which is how one can
differentiate between general and parameter entities.
The base
parameter is the base to use for relative
system identifiers. It is set by XML_SetBase
and may be NULL
. The
publicId
parameter is the public id given in the entity
declaration and may be NULL
. systemId
is the system
identifier specified in the entity declaration and is never NULL
.
There are a couple of ways in which this handler differs from
others. First, this handler returns a status indicator (an
integer). XML_STATUS_OK
should be returned for successful
handling of the external entity reference. Returning
XML_STATUS_ERROR
indicates failure, and causes the
calling parser to return an
XML_ERROR_EXTERNAL_ENTITY_HANDLING
error.
Second, instead of having the user data as its first argument, it
receives the parser that encountered the entity reference. This, along
with the context parameter, may be used as arguments to a call to
XML_ExternalEntityParserCreate
. Using the returned
parser, the body of the external entity can be recursively parsed.
Since this handler may be called recursively, it should not be saving information into global or static variables.
XML_SetExternalEntityRefHandlerArg
void XMLCALL XML_SetExternalEntityRefHandlerArg(XML_Parser p, void *arg)
Set the argument passed to the ExternalEntityRefHandler. If
arg
is not NULL
, it is the new value passed to the
handler set using XML_SetExternalEntityRefHandler
; if arg
is
NULL
, the argument passed to the handler function will be the parser
object itself.
Note:
The type of arg
and the type of the first argument to the
ExternalEntityRefHandler do not match. This function takes a
void *
to be passed to the handler, while the handler
accepts an XML_Parser
. This is a historical accident,
but will not be corrected before Expat 2.0 (at the earliest) to avoid
causing compiler warnings for code that's known to work with this
API. It is the responsibility of the application code to know the
actual type of the argument passed to the handler and to manage it
properly.
XML_SetSkippedEntityHandler
void XMLCALL XML_SetSkippedEntityHandler(XML_Parser p, XML_SkippedEntityHandler handler)
typedef void (XMLCALL *XML_SkippedEntityHandler)(void *userData, const XML_Char *entityName, int is_parameter_entity);
Set a skipped entity handler. This is called in two situations:
- An entity reference is encountered for which no declaration has been read and this is not an error.
- An internal entity reference is read, but not expanded, because
XML_SetDefaultHandler
has been called.
The is_parameter_entity
argument will be non-zero for
a parameter entity and zero for a general entity.
Note: Skipped parameter entities in declarations and skipped general entities in attribute values cannot be reported, because the event would be out of sync with the reporting of the declarations or attribute values
XML_SetUnknownEncodingHandler
void XMLCALL XML_SetUnknownEncodingHandler(XML_Parser p, XML_UnknownEncodingHandler enchandler, void *encodingHandlerData)
typedef int (XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData, const XML_Char *name, XML_Encoding *info); typedef struct { int map[256]; void *data; int (XMLCALL *convert)(void *data, const char *s); void (XMLCALL *release)(void *data); } XML_Encoding;
Set a handler to deal with encodings other than the built in set. This should be done before
XML_Parse
or XML_ParseBuffer
have been called on the
given parser.
If the handler knows how to deal with an encoding
with the given name, it should fill in the info
data
structure and return XML_STATUS_OK
. Otherwise it
should return XML_STATUS_ERROR
. The handler will be called
at most once per parsed (external) entity. The optional application
data pointer encodingHandlerData
will be passed back to
the handler.
The map array contains information for every possible leading
byte in a byte sequence. If the corresponding value is >= 0, then it's
a single byte sequence and the byte encodes that Unicode value. If the
value is -1, then that byte is invalid as the initial byte in a sequence.
If the value is -n, where n is an integer > 1, then n is the number of
bytes in the sequence and the actual conversion is accomplished by a
call to the function pointed at by convert. This function may return -1
if the sequence itself is invalid. The convert pointer may be NULL
if
there are only single byte codes. The data parameter passed to the convert
function is the data pointer from XML_Encoding
. The
string s is NOT null-terminated and points at the sequence of
bytes to be converted.
The function pointed at by release
is called by the
parser when it is finished with the encoding. It may be NULL
.
XML_SetStartNamespaceDeclHandler
void XMLCALL XML_SetStartNamespaceDeclHandler(XML_Parser p, XML_StartNamespaceDeclHandler start);
typedef void (XMLCALL *XML_StartNamespaceDeclHandler)(void *userData, const XML_Char *prefix, const XML_Char *uri);
Set a handler to be called when a namespace is declared. Namespace declarations occur inside start tags. But the namespace declaration start handler is called before the start tag handler for each namespace declared in that start tag.
XML_SetEndNamespaceDeclHandler
void XMLCALL XML_SetEndNamespaceDeclHandler(XML_Parser p, XML_EndNamespaceDeclHandler end);
typedef void (XMLCALL *XML_EndNamespaceDeclHandler)(void *userData, const XML_Char *prefix);
Set a handler to be called when leaving the scope of a namespace declaration. This will be called, for each namespace declaration, after the handler for the end tag of the element in which the namespace was declared.
XML_SetNamespaceDeclHandler
void XMLCALL XML_SetNamespaceDeclHandler(XML_Parser p, XML_StartNamespaceDeclHandler start, XML_EndNamespaceDeclHandler end)
Sets both namespace declaration handlers with a single call.
XML_SetXmlDeclHandler
void XMLCALL XML_SetXmlDeclHandler(XML_Parser p, XML_XmlDeclHandler xmldecl);
typedef void (XMLCALL *XML_XmlDeclHandler)(void *userData, const XML_Char *version, const XML_Char *encoding, int standalone);
Sets a handler that is called for XML declarations and also for
text declarations discovered in external entities. The way to
distinguish is that the version
parameter will be NULL
for text declarations. The encoding
parameter may be NULL
for an XML declaration. The standalone
argument will
contain -1, 0, or 1 indicating respectively that there was no
standalone parameter in the declaration, that it was given as no, or
that it was given as yes.
XML_SetStartDoctypeDeclHandler
void XMLCALL XML_SetStartDoctypeDeclHandler(XML_Parser p, XML_StartDoctypeDeclHandler start);
typedef void (XMLCALL *XML_StartDoctypeDeclHandler)(void *userData, const XML_Char *doctypeName, const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset);
Set a handler that is called at the start of a DOCTYPE declaration,
before any external or internal subset is parsed. Both sysid
and pubid
may be NULL
. The has_internal_subset
will be non-zero if the DOCTYPE declaration has an internal subset.
XML_SetEndDoctypeDeclHandler
void XMLCALL XML_SetEndDoctypeDeclHandler(XML_Parser p, XML_EndDoctypeDeclHandler end);
typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
Set a handler that is called at the end of a DOCTYPE declaration, after parsing any external subset.
XML_SetDoctypeDeclHandler
void XMLCALL XML_SetDoctypeDeclHandler(XML_Parser p, XML_StartDoctypeDeclHandler start, XML_EndDoctypeDeclHandler end);
Set both doctype handlers with one call.
XML_SetElementDeclHandler
void XMLCALL XML_SetElementDeclHandler(XML_Parser p, XML_ElementDeclHandler eldecl);
typedef void (XMLCALL *XML_ElementDeclHandler)(void *userData, const XML_Char *name, XML_Content *model);
enum XML_Content_Type { XML_CTYPE_EMPTY = 1, XML_CTYPE_ANY, XML_CTYPE_MIXED, XML_CTYPE_NAME, XML_CTYPE_CHOICE, XML_CTYPE_SEQ }; enum XML_Content_Quant { XML_CQUANT_NONE, XML_CQUANT_OPT, XML_CQUANT_REP, XML_CQUANT_PLUS }; typedef struct XML_cp XML_Content; struct XML_cp { enum XML_Content_Type type; enum XML_Content_Quant quant; const XML_Char * name; unsigned int numchildren; XML_Content * children; };
Sets a handler for element declarations in a DTD. The handler gets
called with the name of the element in the declaration and a pointer
to a structure that contains the element model. It's the user code's
responsibility to free model when finished with it. See
XML_FreeContentModel
.
There is no need to free the model from the handler, it can be kept
around and freed at a later stage.
The model
argument is the root of a tree of
XML_Content
nodes. If type
equals
XML_CTYPE_EMPTY
or XML_CTYPE_ANY
, then
quant
will be XML_CQUANT_NONE
, and the other
fields will be zero or NULL
. If type
is
XML_CTYPE_MIXED
, then quant
will be
XML_CQUANT_NONE
or XML_CQUANT_REP
and
numchildren
will contain the number of elements that are
allowed to be mixed in and children
points to an array of
XML_Content
structures that will all have type
XML_CTYPE_NAME with no quantification. Only the root node can be type
XML_CTYPE_EMPTY
, XML_CTYPE_ANY
, or
XML_CTYPE_MIXED
.
For type XML_CTYPE_NAME
, the name
field
points to the name and the numchildren
and
children
fields will be zero and NULL
. The
quant
field will indicate any quantifiers placed on the
name.
Types XML_CTYPE_CHOICE
and XML_CTYPE_SEQ
indicate a choice or sequence respectively. The
numchildren
field indicates how many nodes in the choice
or sequence and children
points to the nodes.
XML_SetAttlistDeclHandler
void XMLCALL XML_SetAttlistDeclHandler(XML_Parser p, XML_AttlistDeclHandler attdecl);
typedef void (XMLCALL *XML_AttlistDeclHandler)(void *userData, const XML_Char *elname, const XML_Char *attname, const XML_Char *att_type, const XML_Char *dflt, int isrequired);
Set a handler for attlist declarations in the DTD. This handler is
called for each attribute. So a single attlist declaration
with multiple attributes declared will generate multiple calls to this
handler. The elname
parameter returns the name of the
element for which the attribute is being declared. The attribute name
is in the attname
parameter. The attribute type is in the
att_type
parameter. It is the string representing the
type in the declaration with whitespace removed.
The dflt
parameter holds the default value. It will be
NULL
in the case of "#IMPLIED" or "#REQUIRED" attributes. You can
distinguish these two cases by checking the isrequired
parameter, which will be true in the case of "#REQUIRED" attributes.
Attributes which are "#FIXED" will have also have a true
isrequired
, but they will have the non-NULL
fixed value
in the dflt
parameter.
XML_SetEntityDeclHandler
void XMLCALL XML_SetEntityDeclHandler(XML_Parser p, XML_EntityDeclHandler handler);
typedef void (XMLCALL *XML_EntityDeclHandler)(void *userData, const XML_Char *entityName, int is_parameter_entity, const XML_Char *value, int value_length, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId, const XML_Char *notationName);
Sets a handler that will be called for all entity declarations.
The is_parameter_entity
argument will be non-zero in the
case of parameter entities and zero otherwise.
For internal entities (<!ENTITY foo "bar">
),
value
will be non-NULL
and systemId
,
publicId
, and notationName
will all be NULL
.
The value string is not null-terminated; the length is
provided in the value_length
parameter. Do not use
value_length
to test for internal entities, since it is
legal to have zero-length values. Instead check for whether or not
value
is NULL
.
The notationName
argument will have a non-NULL
value only for unparsed entity
declarations.
XML_SetUnparsedEntityDeclHandler
void XMLCALL XML_SetUnparsedEntityDeclHandler(XML_Parser p, XML_UnparsedEntityDeclHandler h)
typedef void (XMLCALL *XML_UnparsedEntityDeclHandler)(void *userData, const XML_Char *entityName, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId, const XML_Char *notationName);
Set a handler that receives declarations of unparsed entities. These are entity declarations that have a notation (NDATA) field:
<!ENTITY logo SYSTEM "images/logo.gif" NDATA gif>
This handler is obsolete and is provided for backwards compatibility. Use instead XML_SetEntityDeclHandler.
XML_SetNotationDeclHandler
void XMLCALL XML_SetNotationDeclHandler(XML_Parser p, XML_NotationDeclHandler h)
typedef void (XMLCALL *XML_NotationDeclHandler)(void *userData, const XML_Char *notationName, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId);
Set a handler that receives notation declarations.
XML_SetNotStandaloneHandler
void XMLCALL XML_SetNotStandaloneHandler(XML_Parser p, XML_NotStandaloneHandler h)
typedef int (XMLCALL *XML_NotStandaloneHandler)(void *userData);
Set a handler that is called if the document is not "standalone".
This happens when there is an external subset or a reference to a
parameter entity, but does not have standalone set to "yes" in an XML
declaration. If this handler returns XML_STATUS_ERROR
,
then the parser will throw an XML_ERROR_NOT_STANDALONE
error.
Parse position and error reporting functions
These are the functions you'll want to call when the parse
functions return XML_STATUS_ERROR
(a parse error has
occurred), although the position reporting functions are useful outside
of errors. The position reported is the byte position (in the original
document or entity encoding) of the first of the sequence of
characters that generated the current event (or the error that caused
the parse functions to return XML_STATUS_ERROR
.) The
exceptions are callbacks triggered by declarations in the document
prologue, in which case they exact position reported is somewhere in the
relevant markup, but not necessarily as meaningful as for other
events.
The position reporting functions are accurate only outside of the DTD. In other words, they usually return bogus information when called from within a DTD declaration handler.
XML_GetErrorCode
enum XML_Error XMLCALL XML_GetErrorCode(XML_Parser p);
XML_ErrorString
const XML_LChar * XMLCALL XML_ErrorString(enum XML_Error code);
XML_GetErrorCode
.
XML_GetCurrentByteIndex
XML_Index XMLCALL XML_GetCurrentByteIndex(XML_Parser p);
XML_GetCurrentLineNumber
and XML_GetCurrentColumnNumber
.
XML_GetCurrentLineNumber
XML_Size XMLCALL XML_GetCurrentLineNumber(XML_Parser p);
1
.
XML_GetCurrentColumnNumber
XML_Size XMLCALL XML_GetCurrentColumnNumber(XML_Parser p);
XML_GetCurrentByteCount
int XMLCALL XML_GetCurrentByteCount(XML_Parser p);
0
if the event is inside a reference to an internal
entity and for the end-tag event for empty element tags (the later can
be used to distinguish empty-element tags from empty elements using
separate start and end tags).
XML_GetInputContext
const char * XMLCALL XML_GetInputContext(XML_Parser p, int *offset, int *size);
Returns the parser's input buffer, sets the integer pointed at by
offset
to the offset within this buffer of the current
parse position, and set the integer pointed at by size
to
the size of the returned buffer.
This should only be called from within a handler during an active parse and the returned buffer should only be referred to from within the handler that made the call. This input buffer contains the untranslated bytes of the input.
Only a limited amount of context is kept, so if the event triggering a call spans over a very large amount of input, the actual parse position may be before the beginning of the buffer.
If XML_CONTEXT_BYTES
is not defined, this will always
return NULL
.
Billion Laughs Attack Protection
The functions in this section configure the built-in protection against various forms of billion laughs attacks.
XML_SetBillionLaughsAttackProtectionMaximumAmplification
/* Added in Expat 2.4.0. */ XML_Bool XMLCALL XML_SetBillionLaughsAttackProtectionMaximumAmplification(XML_Parser p, float maximumAmplificationFactor);
Sets the maximum tolerated amplification factor
for protection against
billion laughs attacks
(default: 100.0
)
of parser p
to maximumAmplificationFactor
, and
returns XML_TRUE
upon success and XML_FALSE
upon error.
amplification := (direct + indirect) / direct.. while parsing, whereas
direct
is the number of bytes read from the primary document in parsing and
indirect
is the number of bytes added by expanding entities and reading of external DTD files, combined.
For a call to XML_SetBillionLaughsAttackProtectionMaximumAmplification
to succeed:
- parser
p
must be a non-NULL
root parser (without any parent parsers) and maximumAmplificationFactor
must be non-NaN
and greater than or equal to1.0
.
Note: If you ever need to increase this value for non-attack payload, please file a bug report.
Note: Peak amplifications of factor 15,000 for the entire payload and of factor 30,000 in the middle of parsing have been observed with small benign files in practice. So if you do reduce the maximum allowed amplification, please make sure that the activation threshold is still big enough to not end up with undesired false positives (i.e. benign files being rejected).
XML_SetBillionLaughsAttackProtectionActivationThreshold
/* Added in Expat 2.4.0. */ XML_Bool XMLCALL XML_SetBillionLaughsAttackProtectionActivationThreshold(XML_Parser p, unsigned long long activationThresholdBytes);
Sets number of output bytes (including amplification from entity expansion and reading DTD files)
needed to activate protection against
billion laughs attacks
(default: 8 MiB
)
of parser p
to activationThresholdBytes
, and
returns XML_TRUE
upon success and XML_FALSE
upon error.
For a call to XML_SetBillionLaughsAttackProtectionActivationThreshold
to succeed:
- parser
p
must be a non-NULL
root parser (without any parent parsers).
Note: If you ever need to increase this value for non-attack payload, please file a bug report.
Note: Activation thresholds below 4 MiB are known to break support for DITA 1.3 payload and are hence not recommended.
Miscellaneous functions
The functions in this section either obtain state information from the parser or can be used to dynamically set parser options.
XML_SetUserData
void XMLCALL XML_SetUserData(XML_Parser p, void *userData);
userData
when it is finished with the parser. So if you
call this when there's already a pointer there, and you haven't freed
the memory associated with it, then you've probably just leaked
memory.
XML_GetUserData
void * XMLCALL XML_GetUserData(XML_Parser p);
XML_UseParserAsHandlerArg
void XMLCALL XML_UseParserAsHandlerArg(XML_Parser p);
userData
arguments. The user data can still be obtained
using the XML_GetUserData
function.
XML_SetBase
enum XML_Status XMLCALL XML_SetBase(XML_Parser p, const XML_Char *base);
XML_STATUS_ERROR
if
there's no memory to store base, otherwise it's
XML_STATUS_OK
.
XML_GetBase
const XML_Char * XMLCALL XML_GetBase(XML_Parser p);
XML_GetSpecifiedAttributeCount
int XMLCALL XML_GetSpecifiedAttributeCount(XML_Parser p);
atts
array passed to the start tag handler of the first
attribute set due to defaults. It supplies information for the last
call to a start handler. If called inside a start handler, then that
means the current call.
XML_GetIdAttributeIndex
int XMLCALL XML_GetIdAttributeIndex(XML_Parser p);
XML_StartElementHandler
, or -1 if there is no ID
attribute. If called inside a start handler, then that means the
current call.
XML_GetAttributeInfo
const XML_AttrInfo * XMLCALL XML_GetAttributeInfo(XML_Parser parser);
typedef struct { XML_Index nameStart; /* Offset to beginning of the attribute name. */ XML_Index nameEnd; /* Offset after the attribute name's last byte. */ XML_Index valueStart; /* Offset to beginning of the attribute value. */ XML_Index valueEnd; /* Offset after the attribute value's last byte. */ } XML_AttrInfo;
XML_AttrInfo
structures for the
attribute/value pairs passed in the last call to the
XML_StartElementHandler
that were specified
in the start-tag rather than defaulted. Each attribute/value pair counts
as 1; thus the number of entries in the array is
XML_GetSpecifiedAttributeCount(parser) / 2
.
XML_SetEncoding
enum XML_Status XMLCALL XML_SetEncoding(XML_Parser p, const XML_Char *encoding);
NULL
encoding argument to the parser creation functions.
It must not be called after XML_Parse
or XML_ParseBuffer
have been called on the given parser.
Returns XML_STATUS_OK
on success or
XML_STATUS_ERROR
on error.
XML_SetParamEntityParsing
int XMLCALL XML_SetParamEntityParsing(XML_Parser p, enum XML_ParamEntityParsing code);
code
.
The choices for code
are:
XML_PARAM_ENTITY_PARSING_NEVER
XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE
XML_PARAM_ENTITY_PARSING_ALWAYS
XML_SetParamEntityParsing
is called after
XML_Parse
or XML_ParseBuffer
, then it has
no effect and will always return 0.
XML_SetHashSalt
int XMLCALL XML_SetHashSalt(XML_Parser p, unsigned long hash_salt);
XML_Parse
or XML_ParseBuffer
.
Note: This call is optional, as the parser will auto-generate a new random salt value if no value has been set at the start of parsing.
Note: One should not call XML_SetHashSalt
with a
hash salt value of 0, as this value is used as sentinel value to indicate
that XML_SetHashSalt
has not been called. Consequently
such a call will have no effect, even if it returns 1.
XML_UseForeignDTD
enum XML_Error XMLCALL XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
This function allows an application to provide an external subset
for the document type declaration for documents which do not specify
an external subset of their own. For documents which specify an
external subset in their DOCTYPE declaration, the application-provided
subset will be ignored. If the document does not contain a DOCTYPE
declaration at all and useDTD
is true, the
application-provided subset will be parsed, but the
startDoctypeDeclHandler
and
endDoctypeDeclHandler
functions, if set, will not be
called. The setting of parameter entity parsing, controlled using
XML_SetParamEntityParsing
, will be honored.
The application-provided external subset is read by calling the
external entity reference handler set via XML_SetExternalEntityRefHandler
with both
publicId
and systemId
set to NULL
.
If this function is called after parsing has begun, it returns
XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING
and ignores
useDTD
. If called when Expat has been compiled without
DTD support, it returns
XML_ERROR_FEATURE_REQUIRES_XML_DTD
. Otherwise, it
returns XML_ERROR_NONE
.
Note: For the purpose of checking WFC: Entity Declared, passing
useDTD == XML_TRUE
will make the parser behave as if
the document had a DTD with an external subset. This holds true even if
the external entity reference handler returns without action.
XML_SetReturnNSTriplet
void XMLCALL XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
This function only has an effect when using a parser created with
XML_ParserCreateNS
,
i.e. when namespace processing is in effect. The do_nst
sets whether or not prefixes are returned with names qualified with a
namespace prefix. If this function is called with do_nst
non-zero, then afterwards namespace qualified names (that is qualified
with a prefix as opposed to belonging to a default namespace) are
returned as a triplet with the three parts separated by the namespace
separator specified when the parser was created. The order of
returned parts is URI, local name, and prefix.
If
do_nst
is zero, then namespaces are reported in the
default manner, URI then local_name separated by the namespace
separator.
XML_DefaultCurrent
void XMLCALL XML_DefaultCurrent(XML_Parser parser);
XML_SetDefaultHandler
or
XML_SetDefaultHandlerExpand
. It does nothing if there is
not a default handler.
XML_ExpatVersion
XML_LChar * XMLCALL XML_ExpatVersion();
"expat_1.95.1"
).
XML_ExpatVersionInfo
struct XML_Expat_Version XMLCALL XML_ExpatVersionInfo();
typedef struct { int major; int minor; int micro; } XML_Expat_Version;
XML_MAJOR_VERSION
XML_MINOR_VERSION
XML_MICRO_VERSION
XML_GetFeatureList
const XML_Feature * XMLCALL XML_GetFeatureList();
enum XML_FeatureEnum { XML_FEATURE_END = 0, XML_FEATURE_UNICODE, XML_FEATURE_UNICODE_WCHAR_T, XML_FEATURE_DTD, XML_FEATURE_CONTEXT_BYTES, XML_FEATURE_MIN_SIZE, XML_FEATURE_SIZEOF_XML_CHAR, XML_FEATURE_SIZEOF_XML_LCHAR, XML_FEATURE_NS, XML_FEATURE_LARGE_SIZE }; typedef struct { enum XML_FeatureEnum feature; XML_LChar *name; long int value; } XML_Feature;
Returns a list of "feature" records, providing details on how Expat was configured at compile time. Most applications should not need to worry about this, but this information is otherwise not available from Expat. This function allows code that does need to check these features to do so at runtime.
The return value is an array of XML_Feature
,
terminated by a record with a feature
of
XML_FEATURE_END
and name
of NULL
,
identifying the feature-test macros Expat was compiled with. Since an
application that requires this kind of information needs to determine
the type of character the name
points to, records for the
XML_FEATURE_SIZEOF_XML_CHAR
and
XML_FEATURE_SIZEOF_XML_LCHAR
will be located at the
beginning of the list, followed by XML_FEATURE_UNICODE
and XML_FEATURE_UNICODE_WCHAR_T
, if they are present at
all.
Some features have an associated value. If there isn't an
associated value, the value
field is set to 0. At this
time, the following features have been defined to have values:
XML_FEATURE_SIZEOF_XML_CHAR
- The number of bytes occupied by one
XML_Char
character. XML_FEATURE_SIZEOF_XML_LCHAR
- The number of bytes occupied by one
XML_LChar
character. XML_FEATURE_CONTEXT_BYTES
- The maximum number of characters of context which can be
reported by
XML_GetInputContext
.
XML_FreeContentModel
void XMLCALL XML_FreeContentModel(XML_Parser parser, XML_Content *model);
model
argument passed to the
XML_ElementDeclHandler
callback set using XML_ElementDeclHandler
.
This function should not be used for any other purpose.
The following functions allow external code to share the memory
allocator an XML_Parser
has been configured to use. This
is especially useful for third-party libraries that interact with a
parser object created by application code, or heavily layered
applications. This can be essential when using dynamically loaded
libraries which use different C standard libraries (this can happen on
Windows, at least).
XML_MemMalloc
void * XMLCALL XML_MemMalloc(XML_Parser parser, size_t size);
size
bytes of memory using the allocator the
parser
object has been configured to use. Returns a
pointer to the memory or NULL
on failure. Memory allocated in this
way must be freed using XML_MemFree
.
XML_MemRealloc
void * XMLCALL XML_MemRealloc(XML_Parser parser, void *ptr, size_t size);
size
bytes of memory using the allocator the
parser
object has been configured to use.
ptr
must point to a block of memory allocated by XML_MemMalloc
or
XML_MemRealloc
, or be NULL
. This function tries to
expand the block pointed to by ptr
if possible. Returns
a pointer to the memory or NULL
on failure. On success, the original
block has either been expanded or freed. On failure, the original
block has not been freed; the caller is responsible for freeing the
original block. Memory allocated in this way must be freed using
XML_MemFree
.
XML_MemFree
void XMLCALL XML_MemFree(XML_Parser parser, void *ptr);
ptr
. The block must
have been allocated by XML_MemMalloc
or XML_MemRealloc
, or be NULL
.


| Family | {{household.name}} | Total | {{formatFirstNames(household.members)}} |
|
{{numAttending(household)}} | {{totalComing$ | async}} |
|
{{numMissing(household)}} | {{totalMissing$ | async}} | Requests |
|
No Response Yet!
|
|---|


A similar type of story was narrated to me by a teacher of mine on the account of me acting an over-smart: Hence forth this story has been a torchbearer calming me and showing me my height periodically.
In my words it goes like this:
Manohar and Sujata had twin kids named Buddhi and Gyani, both were five years old. On their fifth birthday celebration Manohar discovered that his son Buddhi could dance. They appreciated his talent and motivated him to do better.
On the other hand Gyani was asked to concentrate on studies as he was believed to be an ordinary boy from the crowd.
One day Manohar’s friend Rishi with his wife visited his home. As of conventional tradition the parents wished to showcase how smart their son was, they asked Buddhi to perform a dance. Bravo! It was a wonderful dance they all applauded with an ovation. Gyani was left unnoticed again.
Rishi suggested Manohar to make Buddhi join a dance academy which would allow him to excel in his talent. This was a good idea, Next day Manahor took Buddhi to a renowned dance Academy;
He also took Gyani thinking if he too could learn a little, thus both the child got their admission.A month later Manohar visited his sons dance teacher to get the feedback. He was shocked on hearing his son’s report card. Gyani once unnoticed and assumed inferior was the best student at the Academy and Buddhi was miles behind!
“Judge People on their Potential rather their Outer appearance” The first guys are often found lagging behind in Practical Life and a Backbenchers doing good.