File: getLineNumber.Rd

package info (click to toggle)
r-cran-xml 3.99-0.19-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,688 kB
  • sloc: ansic: 6,659; xml: 2,890; asm: 486; sh: 12; makefile: 2
file content (60 lines) | stat: -rw-r--r-- 2,134 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
\name{getLineNumber}
\alias{getNodeLocation}
\alias{getNodePosition}
\alias{getLineNumber}
\title{Determine the location - file & line number of an (internal) XML node}
\description{
  The \code{getLineNumber} function is used to query the location of an internal/C-level
  XML node within its original "file". This gives us the line number.
  \code{getNodeLocation} gives both the line number and the name of the
  file in which the node is located, handling XInclude files in a
  top-level document  and identifying the included file, as appropriate.
  \code{getNodePosition} returns a simplified version of
  \code{getNodeLocation},
  combining the file and line number into a string and ignoring the
  \code{XPointer} component.

  This is useful when we identify a node with a particular charactestic
  and want to view/edit the original document, e.g. when authoring an
  Docbook article.
}
\usage{
getLineNumber(node, ...)
getNodeLocation(node, recursive = TRUE, fileOnly = FALSE)
}
\arguments{
  \item{node}{the node whose location or line number is of interest}
  \item{\dots}{additional parameters for methods should they be defined.}
  \item{recursive}{a logical value that controls whether the 
    full path of the nested includes is returned or just the
    path in the immediate XInclude element.}
  \item{fileOnly}{a logical value which if \code{TRUE} means that only
  the name of the file is returned, and not the \code{xpointer} attribute or
  line number .}
}

\value{
  \code{getLineNumber} returns an integer.
  \code{getNodeLocation} returns a list with two elements -
  \code{file} and \code{line} which are a character string
  and the integer line number.

  For text nodes, the line number is taken from the previous sibling
  nodes or the parent node.
}
\references{libxml2 }
\author{Duncan Temple Lang}
\seealso{
  \code{\link{findXInclude}}
  \code{\link{xmlParse}}
  \code{\link{getNodeSet}}
  \code{\link{xpathApply}}    
}
\examples{
f = system.file("exampleData", "xysize.svg", package = "XML")
doc = xmlParse(f)
e = getNodeSet(doc, "//ellipse")
sapply(e, getLineNumber)
}
\keyword{IO}
\concept{XML}