|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
cox.jmatt.java.MathTools.demo.XMLUtils
public class XMLUtils
This utility provides basic XML/XSLT processing. It uses MTXProcessor
under the hood and allows more flexible options than the simple parsing
and transforms provided by selections 'K' and 'M' in MathXMLPizza
. The GUI allows dialog-based file selection as well as loadable internal areas
for the XML data and XSLT stylesheet. The XSLT stylesheet can also be checked for validity.
Both the XML data and the XSLT stylesheet can be checked for structural validity. No complex analysis is done; this is the 'checkXML()' method from
MTXPro
applied to either the file specified ('[]XML File' Checkbox checked) or the internal XML. Checking the XSL Stylesheet works the same
way but with the '[]XSLT Sheet' Checkbox determining whether to check the file specified or the internal stylesheet.
The two options that can be specified from the main panel are SAX validation and namespace awareness. Checking the appropriate box enables that feature.
XSLT processing has a lot of flexibility and options. The XML data to transform can come from a file or an internal area, as above, and the XSLT Stylesheet can as well. Checking the box on the main panel reads the stylesheet from a file, unchecking it reads from the XSLT Stylesheet Panel. The Stylesheet can also be checked for structural validity. The internal Stylesheet panel can be loaded and has a lockable 'Clear' button.
Immediately after the internal Stylesheet panel is the XSLT Parameters Panel. Parameters are entered as 'key = value' pairs with one pair per line. An octothorpe ('#') indicates a comment. If present and enabled these parameters are provided to the Transformer during the process. As with the Data and Stylesheet panels this one is loadable with a locked 'Clear' button.
Besides styleshet parameters this Panel can also set output properties. They are included with the standard parameters but the first character must be an asterisk ('*'). The asterisk marks output properties and it is stripped before the property is added. Other than this output properties are identical to stylesheet parameters.In addition to the basic parameter providing capability the Parameter panel can extract parameters from the actual stylesheet. Each parameter must have a specific prefix ('#PARAM' is the default). Any (trimmed) line that begins with this prefix is extracted and added to the Parameter Panel starting with the first character after the prefix. Output properties can also be extracted; merely include the asterisk as the first character after the parameter prefix.
In addition to XSLT, XMLUtils
provides XPath capability. The 'XPath Expressions' panel provides a place to put one or more XPath expressions.
Any expressions here are applied to the XML Data (file or internal) and the results printed and placed in the clipboard. If more than one XPath expression
is entered (or loaded) they are applied, in order, to the data. Checking the 'Transform result' Checkbox sends the final result through the XSL Transform
defined on the main panel (file or internal). If the 'Transform' checkbox is not checked the result is still sent through the XSLT identity transform in order
to make it printable.
Output from all actions (except checking documents) is printed to the screen and can be sent to the clipboard. The 'processMathObject()' Checkbox on the
main panel enables this. If it and the '[]Clip' checkbox (Basic MathPrinter
) are checked the data goes to the clipboard. The output from an XSL
Transform (only!) can be sent to a file. If the file exists it will not be overwritten unless the '[]Overwrite...' box is checked.
The '[]Enable stylesheet properties' box must be checked to include parameters in a transform and at least one parameter must be defined.
The XML Data, XSLT Stylesheet, XSL Transform Parameters and XPath Expressions Panels are all basically identical: the TextArea
is loadable from
a file and its 'Clear' button is locked. If XMLUtils
is NOT instantiated around a Dialog
or Frame
no 'Load' buttons will
be present. As a part of MTDemo
they will always be present. Clicking a 'Load' or 'Choose' button opens a FileDialog
to allow file
selection.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.Panel |
---|
java.awt.Panel.AccessibleAWTPanel |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
XMLUtils()
Construct an instance without a 'Load' button. |
|
XMLUtils(java.awt.Dialog myParent)
Construct an instance around a Dialog . |
|
XMLUtils(java.awt.Frame myParent)
Construct an instance around a Frame . |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent aev)
|
void |
clearData(boolean pOkToClear)
Clear the XML Data area, conditioned on the value pOkToClear. |
void |
clearPizza(boolean pOkToClear)
Clear the XSLT Parameter area, conditioned on the value pOkToClear. |
void |
clearTransform(boolean pOkToClear)
Clear the XSLT stylesheet area, conditioned on the value pOkToClear. |
void |
clearXPath(boolean pOkToClear)
Clear the XPath Expressions area, conditioned on the value pOkToClear. |
java.lang.String |
getFileName(java.lang.String pTitle)
Get the name of a file to load. |
Methods inherited from class java.awt.Panel |
---|
addNotify, getAccessibleContext |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public XMLUtils()
public XMLUtils(java.awt.Frame myParent)
Frame
. The 'Load' button will be available.
public XMLUtils(java.awt.Dialog myParent)
Dialog
. The 'Load' button will be available.
Method Detail |
---|
public void clearData(boolean pOkToClear)
public void clearTransform(boolean pOkToClear)
public void clearPizza(boolean pOkToClear)
public void clearXPath(boolean pOkToClear)
public void actionPerformed(java.awt.event.ActionEvent aev)
actionPerformed
in interface java.awt.event.ActionListener
public java.lang.String getFileName(java.lang.String pTitle)
FileDialog
if it exists. If the FileDialog
does not exist
or the 'Cancel' button is pressed the return value is a blank String.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |