diff options
author | Björn-Egil Dahlberg <[email protected]> | 2016-05-20 17:04:45 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2016-05-20 17:04:45 +0200 |
commit | 6d1458814b1d9b3030f4823461e22a2be8d3fc68 (patch) | |
tree | 56d00fcd6d984b2429740284cf4f0b77004b9ab0 /lib/xmerl/test/xmerl_SUITE_data | |
parent | 2098d573b097566d598ded1444625439ee6c0ae3 (diff) | |
download | otp-6d1458814b1d9b3030f4823461e22a2be8d3fc68.tar.gz otp-6d1458814b1d9b3030f4823461e22a2be8d3fc68.tar.bz2 otp-6d1458814b1d9b3030f4823461e22a2be8d3fc68.zip |
Remove ?line macros
Diffstat (limited to 'lib/xmerl/test/xmerl_SUITE_data')
-rw-r--r-- | lib/xmerl/test/xmerl_SUITE_data/xpath/xpath_abbrev.erl | 403 | ||||
-rw-r--r-- | lib/xmerl/test/xmerl_SUITE_data/xpath/xpath_lib.erl | 212 | ||||
-rw-r--r-- | lib/xmerl/test/xmerl_SUITE_data/xpath/xpath_text.erl | 8 |
3 files changed, 307 insertions, 316 deletions
diff --git a/lib/xmerl/test/xmerl_SUITE_data/xpath/xpath_abbrev.erl b/lib/xmerl/test/xmerl_SUITE_data/xpath/xpath_abbrev.erl index 2e026d7476..aaa80097cd 100644 --- a/lib/xmerl/test/xmerl_SUITE_data/xpath/xpath_abbrev.erl +++ b/lib/xmerl/test/xmerl_SUITE_data/xpath/xpath_abbrev.erl @@ -14,109 +14,109 @@ -include_lib("xmerl/include/xmerl.hrl"). test() -> - ?line {E,_} = xmerl_scan:file("xpath.xml"), + {E,_} = xmerl_scan:file("xpath.xml"), - ?line Res1 = xmerl_xpath:string("blipp",E), - ?line ok = check_node_set("blipp",Res1), - ?line Res2 = xmerl_xpath:string("*",E), - ?line ok = check_node_set("*",Res2), - ?line Res3 = xmerl_xpath:string("blipp/blupp/plopp/text()",E), - ?line ok = check_node_set("blipp/blupp/plopp/text()",Res3), - ?line Res4 = xmerl_xpath:string("blipp/blupp/@att2",E), - ?line ok = check_node_set("blipp/blupp/@att2",Res4), - ?line Res5 = xmerl_xpath:string("blipp/@*",E), - ?line ok = check_node_set("blipp/@*",Res5), - ?line Res6 = xmerl_xpath:string("blipp[2]",E), - ?line ok = check_node_set("blipp[2]",Res6), - ?line Res7 = xmerl_xpath:string("blipp[last()]",E), - ?line ok = check_node_set("blipp[last()]",Res7), - ?line Res8 = xmerl_xpath:string("*/blupp",E), - ?line ok = check_node_set("*/blupp",Res8), - ?line Res9 = xmerl_xpath:string("/myBS_model/blipp[3]/blupp[2]",E), - ?line ok = check_node_set("/myBS_model/blipp[3]/blupp[2]",Res9), - ?line Res10 = xmerl_xpath:string("blipp//plopp",E), - ?line ok = check_node_set("blipp//plopp",Res10), - ?line Res11 = xmerl_xpath:string("//plopp",E), - ?line ok = check_node_set("//plopp",Res11), - ?line Res12 = xmerl_xpath:string("//blupp/plopp",E), - ?line ok = check_node_set("//blupp/plopp",Res12), - ?line Res13 = xmerl_xpath:string(".",E), - ?line ok = check_node_set(".",Res13), - ?line Res14 = xmerl_xpath:string(".//blipp2",E), - ?line ok = check_node_set(".//blipp2",Res14), - ?line Res15 = xmerl_xpath:string(".//blipp2/blupp/plopp/..",E), - ?line ok = check_node_set(".//blipp2/blupp/plopp/..",Res15), - ?line Res16 = xmerl_xpath:string(".//blipp[2]/blupp/plopp/../@att2",E), - ?line ok = check_node_set(".//blipp[2]/blupp/plopp/../@att2",Res16), - ?line Res17 = xmerl_xpath:string(".//blipp/blupp/plopp[2]/../@att2",E), - ?line ok = check_node_set(".//blipp/blupp/plopp[2]/../@att2",Res17), - ?line Res18 = xmerl_xpath:string("blipp[@id='name2']",E), - ?line ok = check_node_set("blipp[@id='name2']",Res18), - ?line Res19 = xmerl_xpath:string("blipp[@id='name2'][3]",E), - ?line ok = check_node_set("blipp[@id='name2'][3]",Res19), - ?line Res20 = xmerl_xpath:string("//blupp[plopp=\"here are some more text\"]",E), - ?line ok = check_node_set("//blupp[plopp=\"here are some more text\"]",Res20), - ?line Res21 = xmerl_xpath:string("//blupp[plopp]",E), - ?line ok = check_node_set("//blupp[plopp]",Res21), - ?line Res22 = xmerl_xpath:string("blipp[@id and @test]",E), - ?line ok = check_node_set("blipp[@id and @test]",Res22). + Res1 = xmerl_xpath:string("blipp",E), + ok = check_node_set("blipp",Res1), + Res2 = xmerl_xpath:string("*",E), + ok = check_node_set("*",Res2), + Res3 = xmerl_xpath:string("blipp/blupp/plopp/text()",E), + ok = check_node_set("blipp/blupp/plopp/text()",Res3), + Res4 = xmerl_xpath:string("blipp/blupp/@att2",E), + ok = check_node_set("blipp/blupp/@att2",Res4), + Res5 = xmerl_xpath:string("blipp/@*",E), + ok = check_node_set("blipp/@*",Res5), + Res6 = xmerl_xpath:string("blipp[2]",E), + ok = check_node_set("blipp[2]",Res6), + Res7 = xmerl_xpath:string("blipp[last()]",E), + ok = check_node_set("blipp[last()]",Res7), + Res8 = xmerl_xpath:string("*/blupp",E), + ok = check_node_set("*/blupp",Res8), + Res9 = xmerl_xpath:string("/myBS_model/blipp[3]/blupp[2]",E), + ok = check_node_set("/myBS_model/blipp[3]/blupp[2]",Res9), + Res10 = xmerl_xpath:string("blipp//plopp",E), + ok = check_node_set("blipp//plopp",Res10), + Res11 = xmerl_xpath:string("//plopp",E), + ok = check_node_set("//plopp",Res11), + Res12 = xmerl_xpath:string("//blupp/plopp",E), + ok = check_node_set("//blupp/plopp",Res12), + Res13 = xmerl_xpath:string(".",E), + ok = check_node_set(".",Res13), + Res14 = xmerl_xpath:string(".//blipp2",E), + ok = check_node_set(".//blipp2",Res14), + Res15 = xmerl_xpath:string(".//blipp2/blupp/plopp/..",E), + ok = check_node_set(".//blipp2/blupp/plopp/..",Res15), + Res16 = xmerl_xpath:string(".//blipp[2]/blupp/plopp/../@att2",E), + ok = check_node_set(".//blipp[2]/blupp/plopp/../@att2",Res16), + Res17 = xmerl_xpath:string(".//blipp/blupp/plopp[2]/../@att2",E), + ok = check_node_set(".//blipp/blupp/plopp[2]/../@att2",Res17), + Res18 = xmerl_xpath:string("blipp[@id='name2']",E), + ok = check_node_set("blipp[@id='name2']",Res18), + Res19 = xmerl_xpath:string("blipp[@id='name2'][3]",E), + ok = check_node_set("blipp[@id='name2'][3]",Res19), + Res20 = xmerl_xpath:string("//blupp[plopp=\"here are some more text\"]",E), + ok = check_node_set("//blupp[plopp=\"here are some more text\"]",Res20), + Res21 = xmerl_xpath:string("//blupp[plopp]",E), + ok = check_node_set("//blupp[plopp]",Res21), + Res22 = xmerl_xpath:string("blipp[@id and @test]",E), + ok = check_node_set("blipp[@id and @test]",Res22). check_node_set("blipp",[E1,E2,E3]) -> - ?line ok = xml_element_name(E1,blipp), - ?line ok = xml_element_name(E2,blipp), - ?line ok = xml_element_name(E3,blipp), + ok = xml_element_name(E1,blipp), + ok = xml_element_name(E2,blipp), + ok = xml_element_name(E3,blipp), ok; check_node_set("*",[E1,E2,E3,E4]) -> - ?line ok = xml_element_name(E1,blipp), - ?line ok = xml_element_name(E2,blipp), - ?line ok = xml_element_name(E3,blipp), - ?line ok = xml_element_name(E4,blipp2), + ok = xml_element_name(E1,blipp), + ok = xml_element_name(E2,blipp), + ok = xml_element_name(E3,blipp), + ok = xml_element_name(E4,blipp2), ok; check_node_set("blipp/blupp/plopp/text()",[T1,T2]) -> - ?line #xmlText{value="here are some text"} = T1, - ?line #xmlText{value="here are some more text"} = T2, + #xmlText{value="here are some text"} = T1, + #xmlText{value="here are some more text"} = T2, ok; check_node_set("blipp/blupp/@att2",[A1,A2]) -> - ?line #xmlAttribute{name=att2} = A1, - ?line #xmlAttribute{name=att2} = A2, + #xmlAttribute{name=att2} = A1, + #xmlAttribute{name=att2} = A2, ok; check_node_set("blipp/@*",[A1,A2,A3,A4]) -> - ?line #xmlAttribute{} = A1, - ?line #xmlAttribute{} = A2, - ?line #xmlAttribute{} = A3, - ?line #xmlAttribute{} = A4, + #xmlAttribute{} = A1, + #xmlAttribute{} = A2, + #xmlAttribute{} = A3, + #xmlAttribute{} = A4, ok; check_node_set("blipp[2]",[E]) -> - ?line #xmlElement{name=blipp, - attributes=[#xmlAttribute{name=id,value="name2"}]} = E, + #xmlElement{name=blipp, + attributes=[#xmlAttribute{name=id,value="name2"}]} = E, ok; check_node_set("blipp[last()]",[E]) -> - ?line #xmlElement{name=blipp, - attributes=[#xmlAttribute{name=id,value="name3"}|_]} = E, + #xmlElement{name=blipp, + attributes=[#xmlAttribute{name=id,value="name3"}|_]} = E, ok; check_node_set("*/blupp",[E1,E2,E3,E4,E5,E6]) -> - ?line ok = xml_element_name(E1,blupp), - ?line ok = xml_element_name(E2,blupp), - ?line ok = xml_element_name(E3,blupp), - ?line ok = xml_element_name(E4,blupp), - ?line ok = xml_element_name(E5,blupp), - ?line ok = xml_element_name(E6,blupp), + ok = xml_element_name(E1,blupp), + ok = xml_element_name(E2,blupp), + ok = xml_element_name(E3,blupp), + ok = xml_element_name(E4,blupp), + ok = xml_element_name(E5,blupp), + ok = xml_element_name(E6,blupp), ok; check_node_set("/myBS_model/blipp[3]/blupp[2]",[E]) -> - ?line #xmlElement{name=blupp, - attributes=[#xmlAttribute{name=att,value="bluppc2"}]}=E, + #xmlElement{name=blupp, + attributes=[#xmlAttribute{name=att,value="bluppc2"}]}=E, ok; check_node_set("blipp//plopp",[#xmlElement{name=plopp},#xmlElement{name=plopp}]) -> ok; check_node_set("//plopp",[E1,E2,E3]) -> - ?line ok = xml_element_name(E1,plopp), - ?line ok = xml_element_name(E2,plopp), - ?line ok = xml_element_name(E3,plopp), + ok = xml_element_name(E1,plopp), + ok = xml_element_name(E2,plopp), + ok = xml_element_name(E3,plopp), ok; check_node_set("//blupp/plopp",[E1,E2,E3]) -> - ?line ok = xml_element_name(E1,plopp), - ?line ok = xml_element_name(E2,plopp), - ?line ok = xml_element_name(E3,plopp), + ok = xml_element_name(E1,plopp), + ok = xml_element_name(E2,plopp), + ok = xml_element_name(E3,plopp), ok; check_node_set(".",[#xmlElement{name=myBS_model}]) -> ok; @@ -129,169 +129,168 @@ check_node_set(".//blipp[2]/blupp/plopp/../@att2",[#xmlAttribute{name=att2,value check_node_set(".//blipp/blupp/plopp[2]/../@att2",[#xmlAttribute{name=att2,value="bluppc"}]) -> ok; check_node_set("blipp[@id='name2']",[E]) -> - ?line #xmlElement{name=blipp, - attributes=[#xmlAttribute{name=id,value="name2"}]}=E, + #xmlElement{name=blipp, + attributes=[#xmlAttribute{name=id,value="name2"}]}=E, ok; check_node_set("blipp[@id='name2'][3]",[]) -> ok; check_node_set("//blupp[plopp=\"here are some more text\"]",[E]) -> - ?line #xmlElement{name=blupp, - content=[_T,#xmlElement{name=plopp,content=C}|_]} = E, - ?line true = lists:keymember("here are some more text",#xmlText.value,C), + #xmlElement{name=blupp, + content=[_T,#xmlElement{name=plopp,content=C}|_]} = E, + true = lists:keymember("here are some more text",#xmlText.value,C), ok; check_node_set("//blupp[plopp]",[E1,E2,E3]) -> - ?line #xmlElement{name=blupp, - content=C1} = E1, - ?line true = lists:keymember(plopp,#xmlElement.name,C1), - ?line #xmlElement{name=blupp, - content=C2} = E2, - ?line true = lists:keymember(plopp,#xmlElement.name,C2), - ?line #xmlElement{name=blupp, - content=C3} = E3, - ?line true = lists:keymember(plopp,#xmlElement.name,C3), + #xmlElement{name=blupp, + content=C1} = E1, + true = lists:keymember(plopp,#xmlElement.name,C1), + #xmlElement{name=blupp, + content=C2} = E2, + true = lists:keymember(plopp,#xmlElement.name,C2), + #xmlElement{name=blupp, + content=C3} = E3, + true = lists:keymember(plopp,#xmlElement.name,C3), ok; check_node_set("blipp[@id and @test]",[E]) -> - ?line #xmlElement{name=blipp, - attributes=Atts} = E, - ?line true = lists:keymember(id,#xmlAttribute.name,Atts), - ?line true = lists:keymember(test,#xmlAttribute.name,Atts), + #xmlElement{name=blipp, + attributes=Atts} = E, + true = lists:keymember(id,#xmlAttribute.name,Atts), + true = lists:keymember(test,#xmlAttribute.name,Atts), ok; check_node_set(Pattern,NodeSet) -> io:format("Pattern: ~p~nNodeSet: ~p~n",[Pattern,NodeSet]), error. xml_element_name(E,N) -> - ?line #xmlElement{name=N} = E, + #xmlElement{name=N} = E, ok. ticket_6873() -> - ?line [#xmlElement{}] = xmerl_xpath:string("//foo[contains(@bar, 'oe')]",element(1,xmerl_scan:string("<foo bar=\"Joe\" />"))), + [#xmlElement{}] = xmerl_xpath:string("//foo[contains(@bar, 'oe')]",element(1,xmerl_scan:string("<foo bar=\"Joe\" />"))), ok. ticket_7496() -> Test = fun(Doc, XPath, Exp) -> - Result = xmerl_xpath:string(XPath, Doc), - ?line Exp = [Name || #xmlElement{name = Name} <- Result], - ok - end, - ?line {Doc1,_} = xmerl_scan:string("<a><b/> <c/> <d/> <e/></a>"), - ?line ok = Test(Doc1, "//b/following::*", [c, d, e]), - ?line ok = Test(Doc1,"//b/following::*[1]", [c]), - ?line ok = Test(Doc1,"//b/following::*[position()=1]", [c]), - ?line ok = Test(Doc1,"//b/following::*[3]", [e]), - ?line ok = Test(Doc1,"//b/following::*[position()=3]", [e]), - ?line ok = Test(Doc1,"//e/preceding::*", [b, c, d]), - ?line ok = Test(Doc1,"//e/preceding::*[1]", [d]), - ?line ok = Test(Doc1,"//e/preceding::*[position()=1]", [d]), - ?line ok = Test(Doc1,"//e/preceding::*[3]", [b]), - ?line ok = Test(Doc1,"//e/preceding::*[position()=3]", [b]), - ?line ok = Test(Doc1,"//b/following::*[position() mod 2=0]", [d]), - ?line ok = Test(Doc1,"//b/self::*", [b]), + Result = xmerl_xpath:string(XPath, Doc), + Exp = [Name || #xmlElement{name = Name} <- Result], + ok + end, + {Doc1,_} = xmerl_scan:string("<a><b/> <c/> <d/> <e/></a>"), + ok = Test(Doc1, "//b/following::*", [c, d, e]), + ok = Test(Doc1,"//b/following::*[1]", [c]), + ok = Test(Doc1,"//b/following::*[position()=1]", [c]), + ok = Test(Doc1,"//b/following::*[3]", [e]), + ok = Test(Doc1,"//b/following::*[position()=3]", [e]), + ok = Test(Doc1,"//e/preceding::*", [b, c, d]), + ok = Test(Doc1,"//e/preceding::*[1]", [d]), + ok = Test(Doc1,"//e/preceding::*[position()=1]", [d]), + ok = Test(Doc1,"//e/preceding::*[3]", [b]), + ok = Test(Doc1,"//e/preceding::*[position()=3]", [b]), + ok = Test(Doc1,"//b/following::*[position() mod 2=0]", [d]), + ok = Test(Doc1,"//b/self::*", [b]), + + {Doc2,_} = xmerl_scan:string("<a><b/> <c><d/></c> <e/> <f><g/></f> <h/> <i><j/></i> <k/></a>"), + ok = Test(Doc2,"//g/preceding::*", [b, c, d, e]), + ok = Test(Doc2, "//g/following::*", [h, i, j, k]), + ok = Test(Doc2,"//g/ancestor::*", [a, f]), + ok = Test(Doc2,"//g/ancestor::*[1]", [f]), + ok = Test(Doc2,"//g/ancestor::*[2]", [a]), + ok = Test(Doc2,"//g/ancestor-or-self::*", [a, f, g]), + ok = Test(Doc2,"//g/ancestor-or-self::*[1]", [g]), + ok = Test(Doc2,"//g/ancestor-or-self::*[2]", [f]), + ok = Test(Doc2,"//g/ancestor-or-self::*[3]", [a]), + ok = Test(Doc2,"/descendant::*", [a, b, c, d, e, f, g, h, i, j, k]), + ok = Test(Doc2,"//f/preceding-sibling::*", [b, c, e]), + ok = Test(Doc2,"//f/following-sibling::*", [h, i, k]), + ok = Test(Doc2,"//f/self::*", [f]), + ok = Test(Doc2,"//f/ancestor::*", [a]), + ok = Test(Doc2,"//f/descendant::*", [g]), + ok = Test(Doc2,"//f/preceding::*", [b, c, d, e]), + ok = Test(Doc2,"//f/following::*", [h, i, j, k]), + ok = Test(Doc2,"//text()[1]/following-sibling::*", [c, e, f, h, i, k]), + + {Doc3,_} = xmerl_scan:file("documentRoot.xml"), + ok = Test(Doc3,"//child",[child,child,child]), + ok = Test(Doc3,"//child[@name='beta']",[child]), + [{xmlAttribute,id,[],[],[],_,1,[],"2",false}] = + xmerl_xpath:string("/documentRoot/parent/child[@name='beta']/@id",Doc3), + ok = Test(Doc3,"/documentRoot/parent/child|/documentRoot/parent/pet", + [child,child,child,pet,pet]), + ok = Test(Doc3,"//*[starts-with(local-name(),'p')]", + [parent,pet,pet]). - ?line {Doc2,_} = xmerl_scan:string("<a><b/> <c><d/></c> <e/> <f><g/></f> <h/> <i><j/></i> <k/></a>"), - ?line ok = Test(Doc2,"//g/preceding::*", [b, c, d, e]), - ?line ok = Test(Doc2, "//g/following::*", [h, i, j, k]), - ?line ok = Test(Doc2,"//g/ancestor::*", [a, f]), - ?line ok = Test(Doc2,"//g/ancestor::*[1]", [f]), - ?line ok = Test(Doc2,"//g/ancestor::*[2]", [a]), - ?line ok = Test(Doc2,"//g/ancestor-or-self::*", [a, f, g]), - ?line ok = Test(Doc2,"//g/ancestor-or-self::*[1]", [g]), - ?line ok = Test(Doc2,"//g/ancestor-or-self::*[2]", [f]), - ?line ok = Test(Doc2,"//g/ancestor-or-self::*[3]", [a]), - ?line ok = Test(Doc2,"/descendant::*", [a, b, c, d, e, f, g, h, i, j, k]), - ?line ok = Test(Doc2,"//f/preceding-sibling::*", [b, c, e]), - ?line ok = Test(Doc2,"//f/following-sibling::*", [h, i, k]), - ?line ok = Test(Doc2,"//f/self::*", [f]), - ?line ok = Test(Doc2,"//f/ancestor::*", [a]), - ?line ok = Test(Doc2,"//f/descendant::*", [g]), - ?line ok = Test(Doc2,"//f/preceding::*", [b, c, d, e]), - ?line ok = Test(Doc2,"//f/following::*", [h, i, j, k]), - ?line ok = Test(Doc2,"//text()[1]/following-sibling::*", [c, e, f, h, i, k]), - - ?line {Doc3,_} = xmerl_scan:file("documentRoot.xml"), - ?line ok = Test(Doc3,"//child",[child,child,child]), - ?line ok = Test(Doc3,"//child[@name='beta']",[child]), - ?line [{xmlAttribute,id,[],[],[],_,1,[],"2",false}] = - xmerl_xpath:string("/documentRoot/parent/child[@name='beta']/@id",Doc3), - ?line ok = Test(Doc3,"/documentRoot/parent/child|/documentRoot/parent/pet", - [child,child,child,pet,pet]), - ?line ok = Test(Doc3,"//*[starts-with(local-name(),'p')]", - [parent,pet,pet]). - functions() -> Test = fun(Doc, XPath, Exp) -> - Result = xmerl_xpath:string(XPath, Doc), - ?line Exp = [begin - case Obj of - #xmlElement{name = EName} -> - EName; - #xmlAttribute{name = AName} -> - AName; - #xmlText{value=Text} -> - Text - end - end|| Obj <- Result], - ok - end, + Result = xmerl_xpath:string(XPath, Doc), + Exp = [begin + case Obj of + #xmlElement{name = EName} -> + EName; + #xmlAttribute{name = AName} -> + AName; + #xmlText{value=Text} -> + Text + end + end|| Obj <- Result], + ok + end, Foo = - "<foo>" - " <bar>" - " <name>Xml</name>" - " <value>1</value>" - " </bar>" - " <bar>" - " <name>Xpath</name>" - " <value>2</value>" - " </bar>" - " <bar>" - " <name>Erlang</name>" - " <value>3</value>" - " </bar>" - "</foo>", + "<foo>" + " <bar>" + " <name>Xml</name>" + " <value>1</value>" + " </bar>" + " <bar>" + " <name>Xpath</name>" + " <value>2</value>" + " </bar>" + " <bar>" + " <name>Erlang</name>" + " <value>3</value>" + " </bar>" + "</foo>", {Doc,_} = xmerl_scan:string(Foo), - ?line ok = Test(Doc,"/foo/bar[name = 'Xml']/value/text()",["1"]), - ?line ok = Test(Doc,"/foo/bar/node()/text()", - ["Xml","1","Xpath","2","Erlang","3"]), - ?line ok = Test(Doc,"/foo/bar[contains(name, 'path')]",[bar]), - ?line ok = Test(Doc,"/foo/bar[starts-with(name, 'X')]",[bar,bar]), - ?line ok = Test(Doc,"/foo/bar[value = string(1)]/value/text()",["1"]), - + ok = Test(Doc,"/foo/bar[name = 'Xml']/value/text()",["1"]), + ok = Test(Doc,"/foo/bar/node()/text()", + ["Xml","1","Xpath","2","Erlang","3"]), + ok = Test(Doc,"/foo/bar[contains(name, 'path')]",[bar]), + ok = Test(Doc,"/foo/bar[starts-with(name, 'X')]",[bar,bar]), + ok = Test(Doc,"/foo/bar[value = string(1)]/value/text()",["1"]), + {Doc2,_}= xmerl_scan:file("purchaseOrder.xml"), - ?line ok = Test(Doc2,"//*[starts-with(local-name(),'c')]", - ['apo:comment',city,city,comment]), - ?line ok = Test(Doc2,"//*[starts-with(name(),'c')]", - [city,city,comment]), - ?line ok = Test(Doc2,"//*[starts-with(name(),'{http://www.example.com/PO1')]", - ['apo:purchaseOrder','apo:comment']). + ok = Test(Doc2,"//*[starts-with(local-name(),'c')]", + ['apo:comment',city,city,comment]), + ok = Test(Doc2,"//*[starts-with(name(),'c')]", + [city,city,comment]), + ok = Test(Doc2,"//*[starts-with(name(),'{http://www.example.com/PO1')]", + ['apo:purchaseOrder','apo:comment']). namespaces() -> {Doc,_} = xmerl_scan:file("purchaseOrder.xml", [{namespace_conformant, true}]), %% Element name using regular namespace and context namespace declaration. - ?line [#xmlElement{nsinfo = {_, "purchaseOrder"}}] = - xmerl_xpath:string("/apo:purchaseOrder", Doc), - ?line [#xmlElement{nsinfo = {_, "purchaseOrder"}}] = - xmerl_xpath:string("/t:purchaseOrder", Doc, [{namespace, [{"t", "http://www.example.com/PO1"}]}]), + [#xmlElement{nsinfo = {_, "purchaseOrder"}}] = + xmerl_xpath:string("/apo:purchaseOrder", Doc), + [#xmlElement{nsinfo = {_, "purchaseOrder"}}] = + xmerl_xpath:string("/t:purchaseOrder", Doc, [{namespace, [{"t", "http://www.example.com/PO1"}]}]), %% Wildcard element name using regular namespace and context namespace declaration. - ?line [#xmlElement{nsinfo = {_, "comment"}}] = - xmerl_xpath:string("./apo:*", Doc), - ?line [#xmlElement{nsinfo = {_, "comment"}}] = - xmerl_xpath:string("./t:*", Doc, [{namespace, [{"t", "http://www.example.com/PO1"}]}]), + [#xmlElement{nsinfo = {_, "comment"}}] = + xmerl_xpath:string("./apo:*", Doc), + [#xmlElement{nsinfo = {_, "comment"}}] = + xmerl_xpath:string("./t:*", Doc, [{namespace, [{"t", "http://www.example.com/PO1"}]}]), %% Attribute name using regular namespace and context namespace declaration. - ?line [#xmlAttribute{nsinfo = {_, "type"}}, #xmlAttribute{nsinfo = {_, "type"}}] = - xmerl_xpath:string("//@xsi:type", Doc), - ?line [#xmlAttribute{nsinfo = {_, "type"}}, #xmlAttribute{nsinfo = {_, "type"}}] = - xmerl_xpath:string("//@t:type", Doc, [{namespace, [{"t", "http://www.w3.org/2001/XMLSchema-instance"}]}]), + [#xmlAttribute{nsinfo = {_, "type"}}, #xmlAttribute{nsinfo = {_, "type"}}] = + xmerl_xpath:string("//@xsi:type", Doc), + [#xmlAttribute{nsinfo = {_, "type"}}, #xmlAttribute{nsinfo = {_, "type"}}] = + xmerl_xpath:string("//@t:type", Doc, [{namespace, [{"t", "http://www.w3.org/2001/XMLSchema-instance"}]}]), %% Wildcard attribute name using regular namespace and context namespace declaration. - ?line [#xmlAttribute{nsinfo = {_, "type"}}, #xmlAttribute{nsinfo = {_, "type"}}] = - xmerl_xpath:string("//@xsi:*", Doc), - ?line [#xmlAttribute{nsinfo = {_, "type"}}, #xmlAttribute{nsinfo = {_, "type"}}] = - xmerl_xpath:string("//@t:*", Doc, [{namespace, [{"t", "http://www.w3.org/2001/XMLSchema-instance"}]}]), - + [#xmlAttribute{nsinfo = {_, "type"}}, #xmlAttribute{nsinfo = {_, "type"}}] = + xmerl_xpath:string("//@xsi:*", Doc), + [#xmlAttribute{nsinfo = {_, "type"}}, #xmlAttribute{nsinfo = {_, "type"}}] = + xmerl_xpath:string("//@t:*", Doc, [{namespace, [{"t", "http://www.w3.org/2001/XMLSchema-instance"}]}]), ok. diff --git a/lib/xmerl/test/xmerl_SUITE_data/xpath/xpath_lib.erl b/lib/xmerl/test/xmerl_SUITE_data/xpath/xpath_lib.erl index f5c65b0c63..e539436c12 100644 --- a/lib/xmerl/test/xmerl_SUITE_data/xpath/xpath_lib.erl +++ b/lib/xmerl/test/xmerl_SUITE_data/xpath/xpath_lib.erl @@ -13,105 +13,102 @@ -include_lib("xmerl/include/xmerl.hrl"). test() -> - ?line {E,_} = xmerl_scan:file("myBS_model.xml"), - ?line Res1 = xmerl_xpath:string("blipp",E), - ?line ok = check_node_set("blipp",Res1), - ?line Res2 = xmerl_xpath:string("//blipp",E), - ?line ok = check_node_set("//blipp",Res2), - ?line Res3 = xmerl_xpath:string("/myBS_model/blipp",E), - ?line ok = check_node_set("/myBS_model/blipp",Res3), - ?line Res4 = xmerl_xpath:string("blipp[@id=\"name1\"]",E), - ?line ok = check_node_set("blipp[@id=\"name1\"]",Res4), - ?line Res5 = xmerl_xpath:string("//blipp[@id=\"name1\"]",E), - ?line ok = check_node_set("//blipp[@id=\"name1\"]",Res5), - ?line Res6 = xmerl_xpath:string("/myBS_model/blipp[@id=\"name1\"]",E), - ?line ok = check_node_set("/myBS_model/blipp[@id=\"name1\"]",Res6). + {E,_} = xmerl_scan:file("myBS_model.xml"), + Res1 = xmerl_xpath:string("blipp",E), + ok = check_node_set("blipp",Res1), + Res2 = xmerl_xpath:string("//blipp",E), + ok = check_node_set("//blipp",Res2), + Res3 = xmerl_xpath:string("/myBS_model/blipp",E), + ok = check_node_set("/myBS_model/blipp",Res3), + Res4 = xmerl_xpath:string("blipp[@id=\"name1\"]",E), + ok = check_node_set("blipp[@id=\"name1\"]",Res4), + Res5 = xmerl_xpath:string("//blipp[@id=\"name1\"]",E), + ok = check_node_set("//blipp[@id=\"name1\"]",Res5), + Res6 = xmerl_xpath:string("/myBS_model/blipp[@id=\"name1\"]",E), + ok = check_node_set("/myBS_model/blipp[@id=\"name1\"]",Res6). check_node_set("blipp",[H1,H2]) -> - ?line #xmlElement{name = blipp} = H1, - ?line #xmlElement{name = blipp} = H2, + #xmlElement{name = blipp} = H1, + #xmlElement{name = blipp} = H2, ok; check_node_set("//blipp",[H1,H2]) -> - ?line #xmlElement{name = blipp} = H1, - ?line #xmlElement{name = blipp} = H2, + #xmlElement{name = blipp} = H1, + #xmlElement{name = blipp} = H2, ok; check_node_set("/myBS_model/blipp",[H1,H2]) -> - ?line #xmlElement{name = blipp} = H1, - ?line #xmlElement{name = blipp} = H2, + #xmlElement{name = blipp} = H1, + #xmlElement{name = blipp} = H2, ok; check_node_set("blipp[@id=\"name1\"]",[H]) -> - ?line H#xmlElement{attributes=#xmlAttribute{name=id,value="name1"}}, + H#xmlElement{attributes=#xmlAttribute{name=id,value="name1"}}, ok; check_node_set("//blipp[@id=\"name1\"]",[H]) -> - ?line H#xmlElement{attributes=#xmlAttribute{name=id,value="name1"}}, + H#xmlElement{attributes=#xmlAttribute{name=id,value="name1"}}, ok; check_node_set("/myBS_model/blipp[@id=\"name1\"]",[H]) -> - ?line H#xmlElement{attributes=#xmlAttribute{name=id,value="name1"}}, + H#xmlElement{attributes=#xmlAttribute{name=id,value="name1"}}, ok. ticket_6873() -> - GetId = - fun(Atts) -> - case lists:keysearch(id,#xmlAttribute.name,Atts) of - {value,#xmlAttribute{value=AttV}} -> AttV; - _ -> novalue - end - end, - Test = - fun(Doc, XPath, Exp) -> - Result = xmerl_xpath:string(XPath, Doc), - Exp = [begin - case Obj of - #xmlElement{name = EName,attributes=Atts} -> - {EName,GetId(Atts)}; - #xmlAttribute{name = AName} -> - AName; - #xmlText{value=Text} -> - Text - end - end|| Obj <- Result], - ok - end, - - - + GetId = fun(Atts) -> + case lists:keysearch(id,#xmlAttribute.name,Atts) of + {value,#xmlAttribute{value=AttV}} -> AttV; + _ -> novalue + end + end, + + Test = fun(Doc, XPath, Exp) -> + Result = xmerl_xpath:string(XPath, Doc), + Exp = [begin + case Obj of + #xmlElement{name = EName,attributes=Atts} -> + {EName,GetId(Atts)}; + #xmlAttribute{name = AName} -> + AName; + #xmlText{value=Text} -> + Text + end + end|| Obj <- Result], + ok + end, + Doc1 = get_doc("e1074"), - ?line ok = Test(Doc1,"/*",[{root,"1"}]), - ?line ok = Test(Doc1,"/root",[{root,"1"}]), - ?line ok = Test(Doc1,"/root/*",[{elem1,"2"},{elem1,"8"},{e,"12"}]), - ?line ok = Test(Doc1,"/root/e",[{e,"12"}]), - ?line ok = Test(Doc1,"//e",[{e,"12"},{e,"4"},{e,"6"},{e,"10"},{e,"11"}]), - ?line ok = Test(Doc1,"//*[name() != 'e']", - [{root,"1"},{elem1,"2"},{elem1,"8"},{elem2,"3"}, - {elem3,"5"},{elem3,"7"},{elem2,"9"}]), - ?line ok = Test(Doc1,"//elem1/e",[{e,"10"},{e,"11"}]), - ?line ok = Test(Doc1,"//elem1//e",[{e,"4"},{e,"6"},{e,"10"},{e,"11"}]), - ?line ok = Test(Doc1,"//*[*]", - [{root,"1"},{elem1,"2"},{elem1,"8"}, - {elem2,"3"},{elem3,"5"}]), - ?line ok = Test(Doc1,"//*[not(*)]", - [{e,"12"},{e,"4"},{elem3,"7"},{e,"6"}, - {elem2,"9"},{e,"10"},{e,"11"}]), + ok = Test(Doc1,"/*",[{root,"1"}]), + ok = Test(Doc1,"/root",[{root,"1"}]), + ok = Test(Doc1,"/root/*",[{elem1,"2"},{elem1,"8"},{e,"12"}]), + ok = Test(Doc1,"/root/e",[{e,"12"}]), + ok = Test(Doc1,"//e",[{e,"12"},{e,"4"},{e,"6"},{e,"10"},{e,"11"}]), + ok = Test(Doc1,"//*[name() != 'e']", + [{root,"1"},{elem1,"2"},{elem1,"8"},{elem2,"3"}, + {elem3,"5"},{elem3,"7"},{elem2,"9"}]), + ok = Test(Doc1,"//elem1/e",[{e,"10"},{e,"11"}]), + ok = Test(Doc1,"//elem1//e",[{e,"4"},{e,"6"},{e,"10"},{e,"11"}]), + ok = Test(Doc1,"//*[*]", + [{root,"1"},{elem1,"2"},{elem1,"8"}, + {elem2,"3"},{elem3,"5"}]), + ok = Test(Doc1,"//*[not(*)]", + [{e,"12"},{e,"4"},{elem3,"7"},{e,"6"}, + {elem2,"9"},{e,"10"},{e,"11"}]), %% contents would be empty in the above expression - ?line [#xmlElement{content=[]}|_] = xmerl_xpath:string("//*[not(*)]",Doc1), - ?line ok = Test(Doc1,"//*[e]",[{root,"1"},{elem1,"8"},{elem2,"3"},{elem3,"5"}]), - ?line ok = Test(Doc1,"//*[count(e)>1]",[{elem1,"8"}]), - ?line ok = Test(Doc1,"//*[not(e) and name() != 'e']", - [{elem1,"2"},{elem3,"7"},{elem2,"9"}]), - ?line ok = Test(Doc1,"/*/*/*/e",[{e,"4"}]), - ?line ok = Test(Doc1,"//*[starts-with(name(), 'el')]", - [{elem1,"2"},{elem1,"8"},{elem2,"3"}, - {elem3,"5"},{elem3,"7"},{elem2,"9"}]), - ?line ok = Test(Doc1,"//*[contains(name(), 'lem1')]", - [{elem1,"2"},{elem1,"8"}]), - ?line ok = Test(Doc1,"/*/e | //elem2/e",[{e,"4"},{e,"12"}]), + [#xmlElement{content=[]}|_] = xmerl_xpath:string("//*[not(*)]",Doc1), + ok = Test(Doc1,"//*[e]",[{root,"1"},{elem1,"8"},{elem2,"3"},{elem3,"5"}]), + ok = Test(Doc1,"//*[count(e)>1]",[{elem1,"8"}]), + ok = Test(Doc1,"//*[not(e) and name() != 'e']", + [{elem1,"2"},{elem3,"7"},{elem2,"9"}]), + ok = Test(Doc1,"/*/*/*/e",[{e,"4"}]), + ok = Test(Doc1,"//*[starts-with(name(), 'el')]", + [{elem1,"2"},{elem1,"8"},{elem2,"3"}, + {elem3,"5"},{elem3,"7"},{elem2,"9"}]), + ok = Test(Doc1,"//*[contains(name(), 'lem1')]", + [{elem1,"2"},{elem1,"8"}]), + ok = Test(Doc1,"/*/e | //elem2/e",[{e,"4"},{e,"12"}]), io:format("Tested ~p~n",[e1074]), Doc2 = get_doc("e1075"), - ?line ok = Test(Doc2,"/*/*[1]",[{elem1,"2"}]), - ?line ok = Test(Doc2,"/root/elem1[2]",[{elem1,"8"}]), + ok = Test(Doc2,"/*/*[1]",[{elem1,"2"}]), + ok = Test(Doc2,"/root/elem1[2]",[{elem1,"8"}]), %% Get all first-born e elements in the document; that is, for all %% e elements with e element siblings, include only the first @@ -119,66 +116,61 @@ ticket_6873() -> %% the document because the [1] predicate applies to e, which %% represents the set of e elements under one element and not to %% //e, which represents the set of e elements in the document. - %% ?line ok = Test(Doc2,"//e[1]",[{e,"4"},{e,"6"},{e,"10"},{e,"12"}]), + %% ok = Test(Doc2,"//e[1]",[{e,"4"},{e,"6"},{e,"10"},{e,"12"}]), %% The following expression retrieves the first e element in the %% document: - %% ?line ok = Test(Doc2,"(//e)[1]",[{e,4}]), - + %% ok = Test(Doc2,"(//e)[1]",[{e,4}]), + %% For all e elements with e element siblings, include only the %% first 3 siblings - %% ?line ok = Test(Doc2,"//e[position() <= 3]",[{e,"4"},{e,"6"},{e,"10"},{e,"11"},{e,"12"}]), + %% ok = Test(Doc2,"//e[position() <= 3]",[{e,"4"},{e,"6"},{e,"10"},{e,"11"},{e,"12"}]), %% Get all last-born e elements in the document; that is, for all %% e elements with e element siblings, include only the last %% sibling - %% ?line ok = Test(Doc2,"//e[last()]",[{e,"4"},{e,"6"},{e,"11"},{e,"12"}]), + %% ok = Test(Doc2,"//e[last()]",[{e,"4"},{e,"6"},{e,"11"},{e,"12"}]), %% Get the last e element in the document - %% ?line ok = Test(Doc2,"(//e)[last()]", [{e,"12"}]), - + %% ok = Test(Doc2,"(//e)[last()]", [{e,"12"}]), io:format("Tested ~p~n",[e1075]), - Doc3 = get_doc("e1076"), - ?line ok = Test(Doc3,"//*[.='cat']",[{elem1,"2"},{elem3,"6"}]), - ?line ok = Test(Doc3,"//*[.='dog']",[]), - ?line ok = Test(Doc3,"//*[contains(.,'cat')]", - [{elem1,"2"},{elem1,"4"},{elem3,"6"}]), - ?line ok = Test(Doc3,"//elem3[contains(.,'cat')]",[{elem3,"6"}]), - ?line ok = Test(Doc3,"//*[contains(child::text(),'cat')]",[{elem1,"2"},{elem1,"4"},{elem3,"6"}]), - ?line ok = Test(Doc3,"//*[count(*)=0 and contains(.,'cat')]",[{elem1,"2"},{elem3,"6"}]), - ?line ok = Test(Doc3,"//*[contains(translate(.,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'),'CAT')]",[{elem1,"2"},{elem1,"4"},{elem1,"7"},{elem3,"6"}]), + ok = Test(Doc3,"//*[.='cat']",[{elem1,"2"},{elem3,"6"}]), + ok = Test(Doc3,"//*[.='dog']",[]), + ok = Test(Doc3,"//*[contains(.,'cat')]", [{elem1,"2"},{elem1,"4"},{elem3,"6"}]), + ok = Test(Doc3,"//elem3[contains(.,'cat')]",[{elem3,"6"}]), + ok = Test(Doc3,"//*[contains(child::text(),'cat')]",[{elem1,"2"},{elem1,"4"},{elem3,"6"}]), + ok = Test(Doc3,"//*[count(*)=0 and contains(.,'cat')]",[{elem1,"2"},{elem3,"6"}]), + ok = Test(Doc3,"//*[contains(translate(.,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'),'CAT')]",[{elem1,"2"},{elem1,"4"},{elem1,"7"},{elem3,"6"}]), io:format("Tested ~p~n",[e1076]), Doc4 = get_doc("e1078"), - ?line ok = Test(Doc4,"//*[@pet='cat']",[{elem1,"2"}]), - ?line ok = Test(Doc4,"//*[@pet='dog']",[{elem1,"7"}]), - ?line ok = Test(Doc4,"//*[contains(@pet,'dog')]", - [{elem1,"3"},{elem1,"7"}]), - ?line ok = Test(Doc4,"//*[@age]",[{elem1,"3"},{elem3,"6"}]), - ?line ok = Test(Doc4,"//elem1[@age]",[{elem1,"3"}]), - ?line ok = Test(Doc4,"//*[@pet and @age]",[{elem1,"3"}]), - ?line ok = Test(Doc4,"//*[contains(translate(@pet,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'),'CAT')]",[{elem1,"2"},{elem1,"4"}]), - - io:format("Tested ~p~n",[e1078]), + ok = Test(Doc4,"//*[@pet='cat']",[{elem1,"2"}]), + ok = Test(Doc4,"//*[@pet='dog']",[{elem1,"7"}]), + ok = Test(Doc4,"//*[contains(@pet,'dog')]", + [{elem1,"3"},{elem1,"7"}]), + ok = Test(Doc4,"//*[@age]",[{elem1,"3"},{elem3,"6"}]), + ok = Test(Doc4,"//elem1[@age]",[{elem1,"3"}]), + ok = Test(Doc4,"//*[@pet and @age]",[{elem1,"3"}]), + ok = Test(Doc4,"//*[contains(translate(@pet,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'),'CAT')]",[{elem1,"2"},{elem1,"4"}]), + io:format("Tested ~p~n",[e1078]), Doc5 = get_doc("e1077"), - ?line ok = Test(Doc5,"id('3')",[{e,"3"}]), + ok = Test(Doc5,"id('3')",[{e,"3"}]), %% Get all e elements directly under element id 3 - %% ?line ok = Test(Doc5,"id('two')/e",[{e,"3"},{e,"4"},{e,"6"}]), - ?line ok = Test(Doc5,"id('two 3 seven the fifth')",[{e,"seven"},{e,"3"},{e,"two"}]), - ?line ok = Test(Doc5,"id('100')",[]), - + %% ok = Test(Doc5,"id('two')/e",[{e,"3"},{e,"4"},{e,"6"}]), + ok = Test(Doc5,"id('two 3 seven the fifth')",[{e,"seven"},{e,"3"},{e,"two"}]), + ok = Test(Doc5,"id('100')",[]), + io:format("Tested ~p~n",[e1077]), ok. - get_doc(Name) -> - ?line {Doc,_} = xmerl_scan:file(Name++".xml"), + {Doc,_} = xmerl_scan:file(Name++".xml"), Doc. diff --git a/lib/xmerl/test/xmerl_SUITE_data/xpath/xpath_text.erl b/lib/xmerl/test/xmerl_SUITE_data/xpath/xpath_text.erl index c3a1fb9c4d..77adde85e9 100644 --- a/lib/xmerl/test/xmerl_SUITE_data/xpath/xpath_text.erl +++ b/lib/xmerl/test/xmerl_SUITE_data/xpath/xpath_text.erl @@ -13,16 +13,16 @@ -include_lib("xmerl/include/xmerl.hrl"). -import(xmerl_xs, - [ xslapply/2, value_of/1, select/2, built_in_rules/2 ]). + [ xslapply/2, value_of/1, select/2, built_in_rules/2 ]). one() -> - ?line {A,_}=xmerl_scan:file('motorcycles.xml'), - ?line [["Suzuki","Yamaha"]] = template(A), + {A,_}=xmerl_scan:file('motorcycles.xml'), + [["Suzuki","Yamaha"]] = template(A), ok. %%% templates, test of OTP-5268 template(E = #xmlElement{name='motorcycles'}) -> - [value_of(select("bike/name/manufacturer/text()",E))]; + [value_of(select("bike/name/manufacturer/text()",E))]; template(E) -> built_in_rules(fun template/1, E). |