/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a object tag, create the new object (with its id) if (qName.Equals("atrezzoobject")) { string atrezzoId = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { atrezzoId = entry.Value.ToString(); } } atrezzo = new Atrezzo(atrezzoId); descriptions = new List <Description>(); atrezzo.setDescriptions(descriptions); } // If it is a resources tag, create the new resources and switch the state else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("name")) { currentResources.setName(entry.Value.ToString()); } } reading = READING_RESOURCES; } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { type = entry.Value.ToString(); } if (entry.Key.Equals("uri")) { path = entry.Value.ToString(); } } // If the asset is not an special one // if( !AssetsController.isAssetSpecial( path ) ) currentResources.addAsset(type, path); } // If it is a description tag, create the new description (with its id) else if (qName.Equals("description")) { description = new Description(); subParser = new DescriptionsSubParser(description, chapter); subParsing = SUBPARSING_DESCRIPTION; } // If it is a condition tag, create new conditions and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a effect tag, create new effects and switch the state else if (qName.Equals("effect")) { subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } } // If it is reading an effect or a condition, spread the call if (subParsing != SUBPARSING_NONE) { //string id = this.atrezzo.getId( ); subParser.startElement(namespaceURI, sName, qName, attrs); } }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary<string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a object tag, create the new object (with its id) if (qName.Equals("atrezzoobject")) { string atrezzoId = ""; foreach (KeyValuePair<string, string> entry in attrs) if (entry.Key.Equals("id")) atrezzoId = entry.Value.ToString(); atrezzo = new Atrezzo(atrezzoId); descriptions = new List<Description>(); atrezzo.setDescriptions(descriptions); } // If it is a resources tag, create the new resources and switch the state else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("name")) currentResources.setName(entry.Value.ToString()); } reading = READING_RESOURCES; } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("type")) type = entry.Value.ToString(); if (entry.Key.Equals("uri")) path = entry.Value.ToString(); } // If the asset is not an special one // if( !AssetsController.isAssetSpecial( path ) ) currentResources.addAsset(type, path); } // If it is a description tag, create the new description (with its id) else if (qName.Equals("description")) { description = new Description(); subParser = new DescriptionsSubParser(description, chapter); subParsing = SUBPARSING_DESCRIPTION; } // If it is a condition tag, create new conditions and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a effect tag, create new effects and switch the state else if (qName.Equals("effect")) { subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } } // If it is reading an effect or a condition, spread the call if (subParsing != SUBPARSING_NONE) { //string id = this.atrezzo.getId( ); subParser.startElement(namespaceURI, sName, qName, attrs); } }
public override void ParseElement(XmlElement element) { XmlNodeList resourcess = element.SelectNodes("resources"), descriptionss = element.SelectNodes("description"), assets, conditions, effects = element.SelectNodes("effect"); string tmpArgVal; string atrezzoId = element.GetAttribute("id"); atrezzo = new Atrezzo(atrezzoId); descriptions = new List<Description>(); atrezzo.setDescriptions(descriptions); if (element.SelectSingleNode("documentation") != null) atrezzo.setDocumentation(element.SelectSingleNode("documentation").InnerText); foreach (XmlElement el in resourcess) { currentResources = new ResourcesUni(); tmpArgVal = el.GetAttribute("name"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentResources.setName(el.GetAttribute(tmpArgVal)); } assets = el.SelectNodes("asset"); foreach (XmlElement ell in assets) { string type = ""; string path = ""; tmpArgVal = ell.GetAttribute("type"); if (!string.IsNullOrEmpty(tmpArgVal)) { type = tmpArgVal; } tmpArgVal = ell.GetAttribute("uri"); if (!string.IsNullOrEmpty(tmpArgVal)) { path = tmpArgVal; } currentResources.addAsset(type, path); } conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentResources.setConditions(currentConditions); } atrezzo.addResources(currentResources); } foreach (XmlElement el in descriptionss) { description = new Description(); new DescriptionsSubParser_(description, chapter).ParseElement(el); this.descriptions.Add(description); } foreach (XmlElement el in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(el); } chapter.addAtrezzo(atrezzo); }
public override void ParseElement(XmlElement element) { XmlNodeList resourcess = element.SelectNodes("resources"), descriptionss = element.SelectNodes("description"), assets, conditions, effects = element.SelectNodes("effect"); string tmpArgVal; string atrezzoId = element.GetAttribute("id"); atrezzo = new Atrezzo(atrezzoId); descriptions = new List <Description>(); atrezzo.setDescriptions(descriptions); if (element.SelectSingleNode("documentation") != null) { atrezzo.setDocumentation(element.SelectSingleNode("documentation").InnerText); } foreach (XmlElement el in resourcess) { currentResources = new ResourcesUni(); tmpArgVal = el.GetAttribute("name"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentResources.setName(el.GetAttribute(tmpArgVal)); } assets = el.SelectNodes("asset"); foreach (XmlElement ell in assets) { string type = ""; string path = ""; tmpArgVal = ell.GetAttribute("type"); if (!string.IsNullOrEmpty(tmpArgVal)) { type = tmpArgVal; } tmpArgVal = ell.GetAttribute("uri"); if (!string.IsNullOrEmpty(tmpArgVal)) { path = tmpArgVal; } currentResources.addAsset(type, path); } conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentResources.setConditions(currentConditions); } atrezzo.addResources(currentResources); } foreach (XmlElement el in descriptionss) { description = new Description(); new DescriptionsSubParser_(description, chapter).ParseElement(el); this.descriptions.Add(description); } foreach (XmlElement el in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(el); } chapter.addAtrezzo(atrezzo); }