public bool Next() { if (null != this.node) { this.node = TreeNavigationHelper.GetContentSibling(this.node, XPathNodeType.Element); if (node != null) { Advance(); } return(null != this.node); } return(false); }
XPathNodeView FillRow(XPathNode ndRow, Shape shape) { object[] columns; XPathNode nd; switch (shape.BindingType) { case BindingType.Text: case BindingType.Attribute: columns = new object[1]; columns[0] = ndRow; return(new XPathNodeView(this, ndRow, columns)); case BindingType.Repeat: columns = new object[1]; nd = TreeNavigationHelper.GetContentChild(ndRow); columns[0] = FillColumn(new ContentIterator(nd, shape), shape); return(new XPathNodeView(this, ndRow, columns)); case BindingType.Sequence: case BindingType.Choice: case BindingType.All: int subShapesCount = shape.SubShapes.Count; columns = new object[subShapesCount]; if (shape.BindingType == BindingType.Sequence && shape.SubShape(0).BindingType == BindingType.Attribute) { FillAttributes(ndRow, shape, columns); } Shape lastSubShape = (Shape)shape.SubShapes[subShapesCount - 1]; if (lastSubShape.BindingType == BindingType.Text) //Attributes followed by simpe content or mixed content { columns[subShapesCount - 1] = ndRow; return(new XPathNodeView(this, ndRow, columns)); } else { nd = TreeNavigationHelper.GetContentChild(ndRow); return(FillSubRow(new ContentIterator(nd, shape), shape, columns)); } default: // should not map to a row #if DEBUG throw new NotSupportedException("Unable to bind row to: " + shape.BindingType.ToString()); #else throw new NotSupportedException(); #endif } }
void PopulateFromXPath(XPathNode nd, XPathStep[] steps, int step) { string ln = steps[step].name.Name; string ns = steps[step].name.Namespace; if (XPathNodeType.Attribute == steps[step].type) { XPathNode ndAttr = nd.GetAttribute(ln, ns, true); if (null != ndAttr) { if (null != ndAttr.SchemaAttribute) { this.rows.Add(ndAttr); } } } else { XPathNode ndChild = TreeNavigationHelper.GetElementChild(nd, ln, ns, true); if (null != ndChild) { int nextStep = step + 1; do { if (steps.Length == nextStep) { if (null != ndChild.SchemaType) { this.rows.Add(ndChild); } } else { PopulateFromXPath(ndChild, steps, nextStep); } ndChild = TreeNavigationHelper.GetElementSibling(ndChild, ln, ns, true); } while (null != ndChild); } } }