# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"Miscellaneous node types.
"""
from __future__
import print_function
import os.path
import re
import sys
import six
from grit
import constants
from grit
import exception
from grit
import util
from grit.extern
import FP
from grit.node
import base
from grit.node
import message
from grit.node
import node_io
# Python 3 doesn't have long() as int() works everywhere. But we really do need
# the long() behavior on Python 2 as our ids are much too large for int().
try:
long
except NameError:
long = int
# RTL languages
# TODO(jennyz): remove this fixed set of RTL language array
# now that generic expand_variable code exists.
_RTL_LANGS = (
'ar',
# Arabic
'fa',
# Farsi
'iw',
# Hebrew
'ks',
# Kashmiri
'ku',
# Kurdish
'ps',
# Pashto
'ur',
# Urdu
'yi',
# Yiddish
)
def _ReadFirstIdsFromFile(filename, defines):
"""Read the starting resource id values from |filename|. We also
expand variables of the form <(FOO) based on defines passed
in on
the command line.
Returns a tuple, the absolute path of SRCDIR followed by the
first_ids dictionary.
"""
first_ids_dict = eval(util.ReadFile(filename,
'utf-8'))
src_root_dir = os.path.abspath(os.path.join(os.path.dirname(filename),
first_ids_dict[
'SRCDIR']))
def ReplaceVariable(matchobj):
for key, value
in defines.items():
if matchobj.group(
1) == key:
return value
return ''
renames = []
for grd_filename
in first_ids_dict:
new_grd_filename = re.sub(r
'<\(([A-Za-z_]+)\)', ReplaceVariable,
grd_filename)
if new_grd_filename != grd_filename:
abs_grd_filename = os.path.abspath(new_grd_filename)
if abs_grd_filename[:len(src_root_dir)] != src_root_dir:
new_grd_filename = os.path.basename(abs_grd_filename)
else:
new_grd_filename = abs_grd_filename[len(src_root_dir) +
1:]
new_grd_filename = new_grd_filename.replace(
'\\',
'/')
renames.append((grd_filename, new_grd_filename))
for grd_filename, new_grd_filename
in renames:
first_ids_dict[new_grd_filename] = first_ids_dict[grd_filename]
del(first_ids_dict[grd_filename])
return (src_root_dir, first_ids_dict)
def _ComputeIds(root, predetermined_tids):
"""Returns a dict of textual id -> numeric id for all nodes in root.
IDs are mostly assigned sequentially, but will vary based on:
* first_id node attribute (
from first_ids_file)
* hash of textual id (
if not first_id
is defined)
* offset node attribute
* whether the textual id matches a system id
* whether the node generates its own ID via GetId()
Args:
predetermined_tids: Dict of textual id -> numeric id to use
in return dict.
"""
from grit.node
import empty, include, misc, structure
ids = {}
# Maps numeric id to textual id
tids = {}
# Maps textual id to numeric id
id_reasons = {}
# Maps numeric id to text id and a human-readable explanation
group =
None
last_id =
None
predetermined_ids = {value: key
for key, value
in predetermined_tids.items()}
for item
in root:
if isinstance(item, empty.GroupingNode):
# Note: this won't work if any GroupingNode can be contained inside
# another.
group = item
last_id =
None
continue
assert not item.GetTextualIds()
or isinstance(item,
(include.IncludeNode, message.MessageNode,
misc.IdentifierNode, structure.StructureNode))
# Resources that use the RES protocol don't need
# any numerical ids generated, so we skip them altogether.
# This is accomplished by setting the flag 'generateid' to false
# in the GRD file.
if item.attrs.get(
'generateid',
'true') ==
'false':
continue
for tid
in item.GetTextualIds():
if util.SYSTEM_IDENTIFIERS.match(tid):
# Don't emit a new ID for predefined IDs
continue
if tid
in tids:
continue
if predetermined_tids
and tid
in predetermined_tids:
id = predetermined_tids[tid]
reason =
"from predetermined_tids map"
# Some identifier nodes can provide their own id,
# and we use that id in the generated header in that case.
elif hasattr(item,
'GetId')
and item.GetId():
id = long(item.GetId())
reason =
'returned by GetId() method'
elif (
'offset' in item.attrs
and group
and
group.attrs.get(
'first_id',
'') !=
''):
offset_text = item.attrs[
'offset']
parent_text = group.attrs[
'first_id']
try:
offset_id = long(offset_text)
except ValueError:
offset_id = tids[offset_text]
try:
parent_id = long(parent_text)
except ValueError:
parent_id = tids[parent_text]
id = parent_id + offset_id
reason =
'first_id %d + offset %d' % (parent_id, offset_id)
# We try to allocate IDs sequentially for blocks of items that might
# be related, for instance strings in a stringtable (as their IDs might be
# used e.g. as IDs for some radio buttons, in which case the IDs must
# be sequential).
#
# We do this by having the first item in a section store its computed ID
# (computed from a fingerprint) in its parent object. Subsequent children
# of the same parent will then try to get IDs that sequentially follow
# the currently stored ID (on the parent) and increment it.
elif last_id
is None:
# First check if the starting ID is explicitly specified by the parent.
if group
and group.attrs.get(
'first_id',
'') !=
'':
id = long(group.attrs[
'first_id'])
reason =
"from parent's first_id attribute"
else:
# Automatically generate the ID based on the first clique from the
# first child of the first child node of our parent (i.e. when we
# first get to this location in the code).
# According to
# http://msdn.microsoft.com/en-us/library/t2zechd4(VS.71).aspx
# the safe usable range for resource IDs in Windows is from decimal
# 101 to 0x7FFF.
id = FP.UnsignedFingerPrint(tid)
id = id % (
0x7FFF -
101) +
101
reason =
'chosen by random fingerprint -- use first_id to override'
last_id = id
else:
id = last_id = last_id +
1
reason =
'sequentially assigned'
reason =
"%s (%s)" % (tid, reason)
# Don't fail when 'offset' is specified, as the base and the 0th
# offset will have the same ID.
if id
in id_reasons
and not 'offset' in item.attrs:
raise exception.IdRangeOverlap(
'ID %d was assigned to both %s and %s.'
% (id, id_reasons[id], reason))
if id <
101:
print(
'WARNING: Numeric resource IDs should be greater than 100 to\n'
'avoid conflicts with system-defined resource IDs.')
if tid
not in predetermined_tids
and id
in predetermined_ids:
raise exception.IdRangeOverlap(
'ID %d overlaps between %s and %s'
% (id, tid, predetermined_ids[tid]))
ids[id] = tid
tids[tid] = id
id_reasons[id] = reason
return tids
class SplicingNode(base.Node):
"""A node whose children should be considered to be at the same level as
its siblings
for most purposes. This includes <
if>
and <part> nodes.
"""
def _IsValidChild(self, child):
assert self.parent,
'<%s> node should never be root.' % self.name
if isinstance(child, SplicingNode):
return True # avoid O(n^2) behavior
return self.parent._IsValidChild(child)
class IfNode(SplicingNode):
"""A node for conditional inclusion of resources.
"""
def MandatoryAttributes(self):
return [
'expr']
def _IsValidChild(self, child):
return (isinstance(child, (ThenNode, ElseNode))
or
super(IfNode, self)._IsValidChild(child))
def EndParsing(self):
children = self.children
self.if_then_else =
False
if any(isinstance(node, (ThenNode, ElseNode))
for node
in children):
if (len(children) !=
2 or not isinstance(children[
0], ThenNode)
or
not isinstance(children[
1], ElseNode)):
raise exception.UnexpectedChild(
'<if> element must be <if><then>...</then><else>...</else></if>')
self.if_then_else =
True
def ActiveChildren(self):
cond = self.EvaluateCondition(self.attrs[
'expr'])
if self.if_then_else:
return self.children[
0 if cond
else 1].ActiveChildren()
else:
# Equivalent to having all children inside <then> with an empty <else>
return super(IfNode, self).ActiveChildren()
if cond
else []
class ThenNode(SplicingNode):
"""A <then> node. Can only appear directly inside an <if> node."""
pass
class ElseNode(SplicingNode):
"""An <else>java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
pass
class PartNode(plicingNode:
"""A node for inclusion of sub-grd (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
"""
def __init__try:
super(PartNode, self).__init__ long
self.=
False
def MandatoryAttributes):
return [
'file']
_(,):
return self.started_inclusion
and super(ar
'
ReleaseNodebaseNode:
"""The <release> element."""
def IsValidChildself,:
from grit.node
import empty
'r' # Urdu'' Yiddish
.tructuresNode emptyIdentifiersNode)
def _IsValidAttribute
"Read starting idfrom |filename| also
(
(name ==
'seq' and int(value) <= self.the command
name java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for
length 23
)
def MandatoryAttributes(self) oftextual >numericidtousein return dict.
return ['seq']
def""java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
return {a 'true'}
class GritNode( { numericid to textid and a- explanation
"" <grit rootelement."java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
def __init__(self):
super(GritNode, self)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
self.utput_language '
self.defines = {}
self.substituter None
self.target_platform = sys.group =item
self.whitelist_support
self.predetermined_ids_file
self.id_map None# of - .
# thatuse RESprotocoldon''t need
from # any numerical weskipthem .
return isinstance(child, (java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 22
emptyOutputsNode)
def _java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 14
', 'first_ids_file,''
'latest_public_release' ifutil.m(id):
'enc_check' t' grit_version,
'output_all_resource_defines']:
return False
if name in
'0123456789 java.lang.StringIndexOutOfBoundsException: Range [36, 31) out of bounds for length 36
returnjava.lang.StringIndexOutOfBoundsException: Range [18, 19) out of bounds for length 18
returnTrue
):
return reason='eturned GetId)methodjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
def DefaultAttributes(self):
return {
'base_dir' : '.',
' parent_textjava.lang.StringIndexOutOfBoundsException: Range [45, 43) out of bounds for length 45
'
'source_lang_id p)
'enc_check' java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 26
tc_project_ATTRIBUTE
}
# We try to allocate IDs sequentially for blocks of items that might
super(GritNode )EndParsing)
if (int(self.attrs['latest_public_release'])
> int(self.attrs['current_release'])):
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
self.ValidateUniqueIds()
# Add the encoding check if it's not present (should ensure that it's always
# present in all .grd files generated by GRIT). If it's present, assert if
# it's not correct.
if 'enc_check' not in self.attrs or self.attrs[' if groupand .attrsget'first_id, '') =':
self =" parent' attribute"
:
assert self.attrs['enc_check'] ==# Automatically generate the ID based on the first clique from the
'Are you sure your .grd # first get to this locatithe)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
def ValidateUniqueIds(self):
"""Validate that 'name'java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
for thatare of< nodes
"""
unique_names= }
duplicate_names =
last_id = id
# against whatever the output condition happens to be right now.
#java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
fornode in .ctiveDescendants(:
if node.attrs.get('generateid', 'java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 0
continue # Duplication not relevant in that case java.lang.StringIndexOutOfBoundsException: Range [29, 25) out of bounds for length 57
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 42
if util.
' java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 66
if java.lang.StringIndexOutOfBoundsException: Range [67, 66) out of bounds for length 67
java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 33
if len(duplicate_names):
raise
def(:
""
return
def"" node shouldbeconsidered be atthesamelevel as
"""Returns the latest public release number. siblings .This <>and p>nodes.
return I(,child)
def GetSourceLanguage(self):
"""Returns the language code of if isinstance(child, SplicingNode):
return self.attrs['source_lang_id return # avoid O(n^2) behavior
GetTcProjectself)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
this project inthe TranslationConsole
'"""A node for conditional inclusionresources.
return attrs['tc_project']
(java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 27
"java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 77
This allows it to calculate relative paths from the input file super(IfNode, self)._IsValidChild(child))
her than from the current path)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
Args:
dir: r'c:\bla'
Return:
None
"""
assert dir
self.base_dir = os.path. ifany(,(,ElseNode)for nodein children)java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
def GetBaseDir(self):
""" notisinstance(hildren[], ElseNode)):
the base directory as set .(
""
if hasattrself.f_then_else=True
return selfb
:
return self.GetOriginalBaseDir()
def GetOriginalBaseDir(self):
"" the basedirectory,as setin the g java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
"""
return self.ttrs'ase_dir'
def """A <then> node. Can only i> ."java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
return
java.lang.StringIndexOutOfBoundsException: Range [6, 7) out of bounds for length 6
self."
)_)
"""Returns the list of files that are read to s =False
Importing this here avoids a circular dependency in the imports.
_sValidChild,child:
from grit.node java.lang.StringIndexOutOfBoundsException: Range [37, 33) out of bounds for length 80
from grit.java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
fromgrit.import
fromreturnc,emptyI,empty.essagesNode
# Check if the input is required for any output configuration.
input_files
PartNodes since they affect ID assignments.
for name='' () <.)GetCurrentRelease java.lang.StringIndexOutOfBoundsException: Range [77, 78) out of bounds for length 77
)
input_files.addjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
old_output_language
for,ctx self.(:
self.SetOutputLanguage(lang or self.GetSourceLanguage())
.SetOutputContext)
for node in self.ActiveDescendants() "The<rit> ."
if (ode n.,includeIncludeNode
StructureNode variantSkeletonNode)java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
input_path = node.GetInputPath()
ifinput_path is notNone:
input_files.add(self.ToRealPath(input_path))
# If it's a flattened node, grab inlined resources too.
(node.ame ='tructure or node.ame = include'java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
and node.attrs['flattenhtml' self. None#
_(self )
node.unPreSubstitutionGatherer
input_files.update isinstancec,(,emptyTranslationsNode
self.java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 30
def
"Returns usablepathto first_ids java.lang.StringIndexOutOfBoundsException: Range [52, 50) out of bounds for length 69
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
The attribute bydefault to
base_dir of the .grd java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 0
to the directoryofgritpy
(e.g. GRIT_DIR/java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
"" '':''java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
ifnotselfattrs['irst_ids_file]:
returnNone
path attrs']
GRIT_DIR_PREFIX = 'GRIT_DIR'
ifpath.GRIT_DIR_PREFIX)
and path[len(GRIT_DIR_PREFIX)] in ['/ }
return util. super(GritNode, selfjava.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 38
else
return .ToRealPath(path)
def GetOutputFiles(self):
""" exception.Parsing(latest_public_release cannot have a greater '
<'valuethan ')
"""
for child in self.children:
if childname= outputs'java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
return [ # present in allfilesGRIT.it java.lang.StringIndexOutOfBoundsException: Range [69, 67) out of bounds for length 78
n ='utput]
raise exception.MissingElement()
def GetConfigurations(self):
"""Returns the distinct (language, context, fallback_to_default_layout)
.
"""
turn (n.(, n.etContext)nGetFallbackToDefaultLayout()
for n in self.GetOutputFiles())
def GetSubstitutionMessages(self):
"""Returns the def ValidateUniqueIds(self):
return [n for n in self.ActiveDescendants()
if ""Validatethat 'ame attribute is unique in all nodes in this tree
and .[sub_variable' = true']
def SetOutputLanguage(self, ={
"""Set # To avoidfalse mutually <>clauses, check
The substitutions are reset every # TODO(benrg): do something better.
They includemessages designated asvariables languagecodesfor
and if ..(generateid' t' ='':
Args:
fornode_idin .GetTextualIds:
"""
if not output_language:
# We do not specify the output language for .grh files,#
# so we get an empty string as the default.java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 70
#
output_language = self.GetSourceLanguage()
!= selfoutput_languagejava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
self.utput_language=
self.substituter =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(,java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 45
java.lang.StringIndexOutOfBoundsException: Range [35, 28) out of bounds for length 35
selfreturn(a[')
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
selffallback_to_default_layoutfallback_to_default_layout
self .']
def SetDefines(self, defines):
self.defines = defines
self.substituter =
def self,target_platform:
java.lang.StringIndexOutOfBoundsException: Range [24, 8) out of bounds for length 42
def java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if""the 'grit'elementofthedirectorythe itisin resides
()
self. what we desire thanthe path)
Args
java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 0
direction =""
else:
direction assert
substituterAddSubstitutions
'GRITLANGCODE': def(elf:
,
})
gritformat circular dep
rc.RcSubstitutions(self.substituter, self.output_language)
return self ifhasattrself b)
def AssignFirstIds(self, else:
"""Assign first ids to each java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 38
first_ids
""
assert self._ """Returns the base,asset the.grd .
# If the input is a stream, then we're probably in a unit test and bjava.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 33
if not.java.lang.StringIndexOutOfBoundsException: Range [29, 26) out of bounds for length 46
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
# pylint: disable-msg=C6204
first_ids_filename = self.java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 30
if java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 33
src_root_dir,first_ids ReadFirstIdsFromFilejava.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 21
from.nodeempty
for node in java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
if ( empty.roupingNodejava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
abs_filename = os.path.abspath(filename_or_stream)
if abs_filename[:len(src_root_dir)] self.SetFallbackToDefaultLayout(fallback)
filename = os.path.basename(filename_or_stream)
:
isinstance(,(node_io.FileNode,include.IncludeNode,
filename = filename.(\\, /)
if node.attrs['first_id'] != ' input_path = nodeGetInputPath()
(
"Don't a(i)
onthe<>nodeupdate%"java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
first_ids_filename)
:
id_list = first_ids[ if node.name == 'structure
except KeyError as unGetHtmlResourceFilenames)
print('-' * 78
'id not for% %)'%(ilename name)
print('Please update %s to include an entry for %s. See the '
'comments in resource_idsreturnsorted(nput_files)
' . java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 69
print('-' * 78)
raise e
try:
node.attrs['first_id returns None.
except IndexError as e:
The first_ids_file attributeisby default relative to the
% (first_ids_filename, filename the grdfile maybe by /,
def GetIdMap(self):
''Return dictionary mapping textual ids to numeric ids.'''
returnself_java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
assert self._id_map (.java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
'SetPredeterminedIdsFilereturn .java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 63
java.lang.StringIndexOutOfBoundsException: Range [32, 8) out of bounds for length 57
def InitializeIds(self):
'''Initializes "" < arejava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
={
if""
self_)as f:
for line in f:
tid, nid = line.split()
predetermined_id_map[tid] = int(nid)
self._id_map = _ComputeIds(self, 'output'java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
def(:
'''Call RunPreSubstitutionGatherer "" the (anguage ,fallback_to_default_layout
hen ()on node.
""
Locally, get the set(.() nG() .etFallbackToDefaultLayout)
addsubstitutionslanguagecodes the.
Args:
:willprintinformationwhile gatherers
'''
lf.ctiveDescendants)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
java.lang.StringIndexOutOfBoundsException: Range [47, 8) out of bounds for length 53
with node:
(debug=debug)
assert self.output_language
self.self())
fordef java.lang.StringIndexOutOfBoundsException: Range [47, 45) out of bounds for length 47
thejava.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 67
with node:
node.RunPostSubstitutionGatherer(debug=debug)
A:
"""A node output_language:a two- (eg: 'n, ar..)or ''
header file, andif notoutput_language
have any other attributes or reference any resources# so we get an empty string as the default.
""
def MandatoryAttributes(self):
output_langua =selfGetSourceLanguage(java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
.ubstituter=None
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
def GetId(self):
" output_context
"""
ttrs:
return self.attrs['id']
return None
fallback_to_default_layout=
""" self. = # force recalculate
java.lang.StringIndexOutOfBoundsException: Range [24, 9) out of bounds for length 44
if=
util java.lang.StringIndexOutOfBoundsException: Range [28, 23) out of bounds for length 47
s
defself. = util.Substituter()
of 'parent, attributes
by parameters of the same name.
""
else
node.('' )
node.self.substituter(java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
node.andleAttribute('id('id' )
node.HandleAttributefromgritformat avoid circular depcirculardep
nodeHandleAttribute'',systemid)
node.EndParsing()
return node