This is the documentation for euXML 2.5 The most things are also available in euXML 2.4. When you want to use the setXML function of euXML 2.3 you have to use the discription about the setOldXML function

index

  • New in version 2.5
  • The differences between xPath and ePath
  • The functions
  • xPath
  • New in version 2.5

    In euXML 2.5 are many bugs fixed, namely in the functions: deleteSpaces, solve_xPath(you can use a slsh on other places then only as seperator of two niveaus) and the argument order in the solve_xPath function is new. To order the tags takes a long time. So when you don't espacially use the order of the tags in the document then set order to 0.
    Example:
    When you wants to select the name of the author and the title of his book. The XML is the following:
    <BOOKS><BOOK><AUTHOR>Tolkien</AUTHOR><TITLE>The lord of the rings</TITLE></BOOK><BOOK><AUTHOR>Rowling</AUTHOR><TITLE>Harry Potter</TITLE></BOOK></BOOKS>
    Then you use the xPath: /BOOKS/BOOK/*
    Now you have to set order to 1 but when you first read al AUTHOR tags with: /BOOKS/BOOK/AUTHOR and then the TITLE tags in an other sequence with: /BOOKS/BOOK/TITLE You haven't to set order to 1 when you set it to 0 it will be faster.

    Changed in euXML 2.5:

  • solve_xPath
  • normalize-space in xPath or deleteSpaces in you program
  • New or changed in euXML 2.4:

  • setXML -new in euXML 2.4
  • deleteTag -new in euXML 2.4
  • setOldXML -the old setXML function (euXML 2.3 and earlier)
  • the function finds has been repaired (in xPath is this the function contains() )
  • New in euXML 2.3 are four functions:

  • solve_xPath
  • setLocation
  • xPath_to_ePath
  • getName
  • Functions already exists in euXML 2.0 (and so also in euXML 2.1 and euXML 2.2):

  • getXML
  • setName
  • setValue
  • getValue
  • setAttribute
  • getAttribute
  • setTag
  • countTags
  • The differences between xPath and ePath

    The difference between ePath and xPath are four:

  • in ePath you set an slash at the end of a tag. in xPath at the beginning.
  • an ePath always selects one tag. The predicate can only have a number an xPath can select more tags
  • When you don't set in predicate in an ePath, he selects the first tag When you don't set a predicate in an xPath, he selects all tags
  • in ePath the root tag is already selected, you don't may give the rootTag in xPath you have to give the root tag
  • The functions

    setOldXML (sequence tree, sequence ePath, sequence XMLString)

    This function setsthe given XMLString in the given tree, at the place given by the ePath e.g.:
    sequence mytree, xml
    mytree = {}
    xml = "<AAA><BBB id=2/></AAA>"
    mytree = setOldXML(mytree, "", xml)
    mytree = setOldXML(mytree, "BBB/", "<BBB id=1>value</BBB>")

    xml in mytree is now "<AAA><BBB id=1>value</BBB></AAA>"

    setXML (sequence tree, sequence ePath, sequence XMLString, integer xmlposition)

    This function sets the given XMLString in the given tree, at the place given by the ePath. When xmlposition is euXML_BEGIN then he starts an new session of setting an long XML string. When xmlposition is euXML_FOLLOW he goes further with setting the XML you have to give the same ePath as the first time with xmlposition is euXML_BEGIN. The last time you call setXML your xmlposition is euXML_END. You can also set the whole xml in one time xmlposition is then euXML_BEGIN + euXML_END
    e.g.:
    sequence mytree, xml
    mytree = {}
    xml = "<AAA><B"
    mytree = setXML(mytree, "", xml, euXML_BEGIN)
    xml = "BB id=2/></"
    mytree = setXML(mytree, "", xml, euXML_FOLLOW)
    xml = "AA"
    mytree = setXML(mytree, "", xml, euXML_FOLLOW)
    xml = "A>"
    mytree = setXML(mytree, "", xml, euXML_END)
    mytree = setXML(mytree, "BBB/", "<BBB id=1>value</BBB>", euXML_BEGIN + euXML_END)

    xml in mytree is now "<AAA><BBB id=1>value</BBB></AAA>"

    getXML (sequence tree, sequence ePath)

    Gives the XMLString of the tree at the selected location by ePath
    e.g. :
    (see above)
    sequence mytree, xml
    xml = getXML(mytree, "BBB[1]/")

    xml is now "<BBB id=1>value</BBB>"

    setName (sequence tree, sequence ePath, sequence name)

    this function changes the name of the selected tag by ePath. It returns the new tree

    e.g. :
    (see above)
    mytree = setName(mytree, "", "HEADER")
    xml = getXML(mytree, "")

    xml is now "<HEADER><BBB id=1>value</BBB></HEADER>"

    getName (sequence tree, sequence ePath)

    This function returns the name selected by the ePath.

    e.g. :
    (see above)
    xml = getName(mytree, "*[1]/")

    xml is now "BBB"

    setValue (sequence tree, sequence ePath, sequence value)

    This function sets the given value to a tag selected by the ePath.

    e.g. :
    (see above)
    mytree = setValue(mytree, "BBB/", "The new value")
    xml = getXML(mytree, "*/")

    xml is now "<BBB id=1>The new value</BBB>"

    getValue (sequence tree, sequence ePath)

    This function gives the value of the tag selected by ePath.

    e.g. :
    (see above)
    xml = getValue(mytree, "*[1]/")

    xml is now "The new value"

    setAttribute (sequence tree, sequence ePath, sequence name, object value)

    This function sets a new attribute in the selected tag, when the the attribute with name name doesn't exist. Otherwise it changes only the value to value.
    e.g. :
    (see above)
    mytree = setAttribute(mytree, "", "kind", "nothing")
    mytree = setAttribute(mytree, "BBB[1]/", "id", 3)
    xml = getXML(mytree, "")

    xml is now "<HEADER kind="nothing"><BBB id=3>The new value</BBB></HEADER>"

    getAttribute (sequence tree, sequence ePath, sequence name)

    This function gives the value of the attribute name of the selected tag it gives an atom or an sequence.

    e.g. :
    (see above)
    xml = getAttribute(mytree, "", "kind")

    xml is now "nothing"

    setTag (sequence tree, sequence ePath, sequence name)

    This function adds a new child tag at the end of the children of the by ePath selected tag. The tag gets the name name. When the hasn't children but a value it overwrites the value.

    e.g. :
    mytree = setTag(mytree, "", "BBB")
    xml = getXML(mytree, "")

    xml is now "<HEADER kind="nothing"><BBB id=3>The new value</BBB><BBB/></HEADER>"

    countTags (sequence tree, sequence ePath, sequence name)

    This function counts the children of the selected tag with the name name. When name = "*" he counts all children.

    e.g. :
    integer a, b
    sequence xml , mytree
    mytree = {}
    xml = "<A><B/><C/></A>"
    mytree = setXML(mytree, "", xml, euXML_BEGIN + euXML_END)
    a = countTags(mytree, "", "B")
    b = countTags(mytree, "", "*")

    a is now 1 and b is now 2

    deleteTag (sequence tree, sequence ePath)

    This function deletes the tag selected by the ePath from you XML file
    e.g.:
    sequence xml , mytree
    mytree = {}
    xml = "<A><B/><C/></A>"
    mytree = setXML(mytree, "", xml, euXML_BEGIN + euXML_END)
    mytree = deleteTag(mytree, "B/")
    xml = getXML(mytree, "")

    xml is now <A><C/><A>

    setLocation (sequence xPath)

    This function set the current location. This is only used in solve_xPath When you gives a absolute path (beginning with a slash) it makes a new location. Otherwise it uses the setted location. You can use all kind of xPath's.

    xPath_to_ePath (sequence xPath)

    This function sets an unique xPath to an ePath. An unique xPath look likes this: /AAA[1]/*[2]
    When you want to change an xPath after getting it from solve_xPath you can make an ePath with this function. Mostly you will get ePath's from solve_xPath, but you can change this.
    Because also solve_xPath uses xPath_to_ePath to make the ePath's.
    e.g. :
    sequence ePath
    ePath = xPath_to_ePath("/AAA[1]/*[2]")

    ePath is now "*[2]/"

    solve_xPath (sequence tree, sequence xPath, integer giveePath, integer order)

    This function solves the given xPath. Itr gives a sequence of xPath's ( when giveePath = 0 otherwise ePath's) . When you have setted a location you can use this by using no slash at the begining. When order = 1 he sorts the results to the order of the opening tags in the XMLString. First the parent then his children then the next parent and his children and so on. When order is 0 then he is much faster but he doesn't order the tags. You can use this when you are sure there is only one result or when you only want to count the results.

    xPath

  • The functions
  • Relational expressions
  • Axises
  • The functions in xPath which are allowed in euXML 2.5 are:

  • concat
  • substring
  • string
  • substring-before
  • substring-after
  • string-length
  • contains
  • normalize-space
  • starts-with
  • last
  • position
  • name
  • ceiling
  • floor
  • number
  • round
  • boolean
  • true
  • false
  • not
  • concat (sequence value1, sequence value2, sequence value 3 )

    Makes of all the value's one string.
    e.g. :
    string = concat("abc", "def", "ghi")
    string is now "abcdefghi"

    substring (sequence string, integer start, integer length)

    gives the part of string .
    e.g. :
    string = substring("abcdefghi", 4, 3)
    string is now "def"

    string (object value)

    Makes a string of the given argument. It gives also when you do for example string(boolean("true")) it gives "1" and not "true", because a boolean is an integer 0 or 1. When you give that to the function string it returns the number 0 or 1 as string.

    substring-before (sequence string, sequence substr)

    Gives the part of string before substr.
    e.g. :
    string = substring-before("abcdefghi", "def")
    string is now "abc"

    substring-after (sequence string, sequence substr)

    Gives the part of string after substr.
    e.g. :
    string = substring-after("abcdefghi", "def")
    string is now "ghi"

    string-length (sequence string)

    Gives the length of a string.
    e.g.:
    number = string-length("abcdefghi")
    number is now 9

    contains (sequence string, sequence substr)

    Gives 1 (true) when substr is found in substr other wise 0 (false).
    e.g. :
    boolean = contains("abcdefghi", "bcd")
    boolean is now 1 (this is true)

    normalize-space (sequence string)

    deletes the spaces left and right.
    e.g. :
    string = normalize-space(" abcdefghi ")
    string is now "abcdefghi"

    starts-with (sequence string, sequence substr)

    return true when string starts with substr. Otherwise false.
    e.g. :
    boolean = starts-with("abcdefghi", " abc")
    boolean is now false or 0

    last ()

    Gives the number of the last tag with the name given before the predicate. You can use this to get the new setted tag.
    e.g. :
    <AAA>
    <BBB/>
    <BBB/>
    <CCC/>
    <BBB/>
    </AAA>
    /AAA[1]/BBB[last()] selects tag /AAA[1]/BBB[3]
    /AAA[1]/*[last()] selects tag /AAA[1]/*[4]

    position ()

    The same as last but gives the position of the current tag
    e.g. :
    /AAA[1]/BBB[2] is the same as /AAA[1]/BBB[position() = 2]

    name ()

    gives the name of the curent tag.
    e.g. :
    /AAA/*[name() = "BBB" and position = 2] is the same as /AAA/BBB[position() = 2]

    ceiling (atom number)

    e.g. number = ceiling(3.14) number is now 4
    number = ceiling(6.67) number is now 7

    floor (atom number)

    e.g. : number = ceiling(3.14) number is now 3
    number = ceiling(6.67) number is now 6

    number (object number)

    Makes an atom of a string.
    e.g. :
    number = number("-123.34")
    number is now -123.34

    round(atom number)

    rounds a number.
    e.g. : number = ceiling(3.14) number is now 3
    number = ceiling(6.67) number is now 7

    boolean (object boolean)

    Converts a number or string to a boolean. "true" -> True, "false" -> False 1 -> True, 0 -> False

    true ()

    Returns true

    false ()

    Returns false

    not (atom boolean)

    Returns True when boolean is False
    Returns False when boolean is True

    The relational expressions

  • =
  • !=
  • <
  • <=
  • >
  • >=
  • Tag: in an xPath you can use spaces between operator and expressions. In your XML file you have to write this: 'attribname="attribvalue"' 'attribname = "attribvalue"' doesn't work.

    Than there are the operators 'and' and 'or'

    There aren't yet mathematical operators (maybe in euXML 2.6)

    Axises

  • self
    selects the current tag.
  • child
    selects the child of the current tag You can alos type nothing for 'child::'
  • parent
    selects the parent tag
  • ancestor
    selects the parent tags (also the parent of the parent)
  • ancestor-or-self
    Selects ancestor and the tag self.
  • descendant
    Selects all child tags (also the children of the children)
  • descendant-or-self
    Selects descendant and the current tag self.
  • attribute
    Selects the attribute of the current tag Only inside predicates.
    You can also type '@' for 'attribute::'
  • Inside predicates you can't use slashes but only only one axis.
    To select the CCC and the DDD tags of a BBB tag with CCC attribute id = 1:
    You should use:
    /AAA/BBB[CCC/@id = 1]/*
    But in euXML you must use this:
    /AAA/BBB/CCC[@id = 1]/parent::BBB/* or
    /AAA/BBB/CCC[@id = 1]/parent::*/*

    In euXML you can use '//' but there is a difference between xPath and euXML xPath:
    //* selects all tags in standard xPath, but in euXML it doesn't select the root tag. To select also the root tag, you can use the xPath: '/descendant-or-self::*'

    The functions works only in the predicates. But it is possible to do this by using that:
    /AAA/BBB is the same as /AAA/*[name() = "BBB"]