/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: LiteralElement.java,v 1.2.4.1 2005/09/13 12:38:33 pvedula Exp $
*/
/**
* @author Jacek Ambroziak
* @author Santiago Pericas-Geertsen
* @author Morten Jorgensen
*/
// True if all attributes of this LRE are unique, i.e. they all have
// different names. This flag is set to false if some attribute
// names are not known at compile time.
private boolean _allAttributesUnique = false;
/**
* Returns the QName for this literal element
*/
return _qname;
}
/**
* Displays the contents of this literal element
*/
}
/**
* Returns the namespace URI for which a prefix is pointing to
*/
if (_literalElemParent != null) {
return result;
}
}
return _accessedPrefixes != null ?
}
/**
* Method used to keep track of what namespaces that are references by
* this literal element and its attributes. The output must contain a
* definition for each namespace, so we stuff them in a hashtable.
*/
// Check if the parent has a declaration for this namespace
if (_literalElemParent != null) {
return;
}
}
// Check if we have any declared namesaces
if (_accessedPrefixes == null) {
_accessedPrefixes = new Hashtable();
}
else {
if (!declared) {
// Check if this node has a declaration for this namespace
return;
else
}
}
}
}
}
/**
* Translates the prefix of a QName according to the rules set in
* the attributes of xsl:stylesheet. Also registers a QName to assure
* that the output element contains the necessary namespace declarations.
*/
// Break up the QName and get prefix:localname strings
// Treat default namespace as "" and not null
return(XMLNS_STRING);
// Check if we must translate the prefix
if (alternative != null) {
}
// Get the namespace this prefix refers to
// Register the namespace as accessed
// Construct the new name for the element (may be unchanged)
else
return(localname);
}
/**
* Add an attribute to this element
*/
if (_attributeElements == null) {
}
}
/**
* Set the first attribute of this element
*/
if (_attributeElements == null) {
}
}
/**
* Type-check the contents of this element. The element itself does not
* need any type checking as it leaves nothign on the JVM's stack.
*/
// Type-check all attributes
if (_attributeElements != null) {
for (int i = 0; i < count; i++) {
}
}
}
/**
* This method starts at a given node, traverses all namespace mappings,
* and assembles a list of all prefixes that (for the given node) maps
* to _ANY_ namespace URI. Used by literal result elements to determine
*/
while (prefixes.hasMoreElements()) {
}
}
}
}
}
/**
* Determines the final QName for the element and its attributes.
* Registers all namespaces that are used by the element/attributes
*/
stable.setCurrentNode(this);
// Check if in a literal element context
}
// Process all attributes and register all namespaces they use
for (int i = 0; i < count; i++) {
// Handle xsl:use-attribute-sets. Attribute sets are placed first
// in the vector or attributes to make sure that later local
// attributes can override an attributes in the set.
}
}
// Handle xsl:extension-element-prefixes
}
// Handle xsl:exclude-result-prefixes
}
else {
// Ignore special attributes (e.g. xmlns:prefix and xmlns)
{
continue;
}
// Handle all other literal attributes
}
}
// Register all namespaces that are in scope, except for those that
// are listed in the xsl:stylesheet element's *-prefixes attributes
while (include.hasMoreElements()) {
}
}
}
// Process all attributes and register all namespaces they use
for (int i = 0; i < count; i++) {
// Handle xsl:extension-element-prefixes
}
// Handle xsl:exclude-result-prefixes
}
}
}
protected boolean contextDependent() {
return dependentContents();
}
/**
* Compiles code that emits the literal element to the output handler,
* first the start tag, then namespace declaration, then attributes,
* then the element contents, and then the element end tag. Since the
* value of an attribute may depend on a variable, variables must be
* compiled first.
*/
// Check whether all attributes are unique.
// Compile code to emit element start tag
// The value of an attribute may depend on a (sibling) variable
int j=0;
while (j < elementCount()) {
}
j++;
}
// Compile code to emit namespace attributes
if (_accessedPrefixes != null) {
boolean declaresDefaultNS = false;
while (e.hasMoreElements()) {
{
declaresDefaultNS = true;
}
}
}
/*
* If our XslElement parent redeclares the default NS, and this
* element doesn't, it must be redeclared one more time.
*/
{
}
}
// Output all attributes
if (_attributeElements != null) {
for (int i = 0; i < count; i++) {
if (!(node instanceof XslAttribute)) {
}
}
}
// Compile code to emit attributes and child elements
// Compile code to emit element end tag
}
/**
* Return true if the output method is html.
*/
private boolean isHTMLOutput() {
}
/**
* Return the ElemDesc object for an HTML element.
* Return null if the output method is not HTML or this is not a
* valid HTML element.
*/
if (isHTMLOutput()) {
}
else
return null;
}
/**
* Return true if all attributes of this LRE have unique names.
*/
public boolean allAttributesUnique() {
return _allAttributesUnique;
}
/**
* Check whether all attributes are unique.
*/
private boolean checkAttributesUnique() {
boolean hasHiddenXslAttribute = canProduceAttributeNodes(this, true);
return false;
if (_attributeElements != null) {
for (int i = 0; i < numAttrs; i++) {
if (node instanceof UseAttributeSets) {
return false;
}
else if (node instanceof XslAttribute) {
if (attrsTable == null) {
attrsTable = new Hashtable();
for (int k = 0; k < i; k++) {
if (n instanceof LiteralAttribute) {
}
}
}
if (attrName instanceof AttributeValueTemplate) {
return false;
}
else if (attrName instanceof SimpleAttributeValue) {
return false;
}
}
}
}
}
return true;
}
/**
* Return true if the instructions under the given SyntaxTreeNode can produce attribute nodes
* to an element. Only return false when we are sure that no attribute node is produced.
* Return true if we are not sure. If the flag ignoreXslAttribute is true, the direct
* <xsl:attribute> children of the current node are not included in the check.
*/
for (int i = 0; i < size; i++) {
continue;
else
return false;
}
// Cannot add an attribute to an element after children have been added to it.
// We can safely return false when the instruction can produce an output node.
else if (child instanceof LiteralElement
|| child instanceof XslElement
|| child instanceof ProcessingInstruction)
return false;
else if (child instanceof XslAttribute) {
if (ignoreXslAttribute)
continue;
else
return true;
}
// In general, there is no way to check whether <xsl:call-template> or
// <xsl:apply-templates> can produce attribute nodes. <xsl:copy> and
// <xsl:copy-of> can also copy attribute nodes to an element. Return
// true in those cases to be safe.
else if (child instanceof CallTemplate
|| child instanceof ApplyTemplates
return true;
&& canProduceAttributeNodes(child, false)) {
return true;
}
for (int k = 0; k < num; k++) {
if (canProduceAttributeNodes(chooseChild, false))
return true;
}
}
}
}
return false;
}
}