K
Kyle X.
Hello, I have beenhaving trouble trying to transform some REXML to
Nokogiri, and from my reading online I cannot find the proper way to
write it using Nokogiri. Here are the two examples I am having trouble
with:
Case 1)
<IfcWallStandardCase id="i17855">
<Representation>
<IfcProductDefinitionShape id="i17925">
<Representations id="i17928" exp:cType="list">
<IfcShapeRepresentation expos="0" xsi:nil="true"
ref="i17886"/>
<IfcShapeRepresentation expos="1" xsi:nil="true"
ref="i17919"/>
</Representations>
</IfcProductDefinitionShape>
</Representation>
</IfcWallStandardCase>
I am trying to get the reference for expos="1", and I had this working
with using REXML with the following -
XPath.match( $doc, "//IfcWallStandardCase//*[@pos='1']" )
With nokogiri I can get it to read both pos 0 and 1, using .css and
xpath-
$doc_noko.css("uosNS|IfcWallStandardCase uosNS|IfcShapeRepresentation",
{"uosNS" => $http})
and
$doc_noko.xpath("//uosNS:IfcWallStandardCase//uosNS:IfcShapeRepresentation",
{"uosNS" => $http})
But cannot figure out how to get it to read only pos=1 using either
method and continuously get error or nil.
Case 2)
<IfcDirection id="i1574">
<DirectionRatios id="i1577" exp:cType="list">
<exp:double-wrapper pos="0">1.</exp:double-wrapper>
<exp:double-wrapper pos="1">0.</exp:double-wrapper>
<exp:double-wrapper pos="2">0.</exp:double-wrapper>
</DirectionRatios>
</IfcDirection>
The issue I am having here is that I am reading this with Nokogiri using
xpath and the colon in exp:double is giving me trouble since the xpath
is written -
ref = "i1574"
$doc_noko.xpath("//uosNS:*[@id='#{ref}']//uosNS:exp:double-wrapper",
{"uosNS" => $http}).map {|element| element.text}
I am guessing that it would be easier to use .css here rather than
xpath. So I have tried using it but cannot seem to get it correct.
Trying -
ref = "i1574"
$doc_noko.css("uosNS|#{ref} uosNS|exp:double-wrapper", {"uosNS" =>
$http}).map {|element| element.text}
I read in a previous post that you call the ref using #{} for css,
but this returns nil for me.
Any ideas?
Nokogiri, and from my reading online I cannot find the proper way to
write it using Nokogiri. Here are the two examples I am having trouble
with:
Case 1)
<IfcWallStandardCase id="i17855">
<Representation>
<IfcProductDefinitionShape id="i17925">
<Representations id="i17928" exp:cType="list">
<IfcShapeRepresentation expos="0" xsi:nil="true"
ref="i17886"/>
<IfcShapeRepresentation expos="1" xsi:nil="true"
ref="i17919"/>
</Representations>
</IfcProductDefinitionShape>
</Representation>
</IfcWallStandardCase>
I am trying to get the reference for expos="1", and I had this working
with using REXML with the following -
XPath.match( $doc, "//IfcWallStandardCase//*[@pos='1']" )
With nokogiri I can get it to read both pos 0 and 1, using .css and
xpath-
$doc_noko.css("uosNS|IfcWallStandardCase uosNS|IfcShapeRepresentation",
{"uosNS" => $http})
and
$doc_noko.xpath("//uosNS:IfcWallStandardCase//uosNS:IfcShapeRepresentation",
{"uosNS" => $http})
But cannot figure out how to get it to read only pos=1 using either
method and continuously get error or nil.
Case 2)
<IfcDirection id="i1574">
<DirectionRatios id="i1577" exp:cType="list">
<exp:double-wrapper pos="0">1.</exp:double-wrapper>
<exp:double-wrapper pos="1">0.</exp:double-wrapper>
<exp:double-wrapper pos="2">0.</exp:double-wrapper>
</DirectionRatios>
</IfcDirection>
The issue I am having here is that I am reading this with Nokogiri using
xpath and the colon in exp:double is giving me trouble since the xpath
is written -
ref = "i1574"
$doc_noko.xpath("//uosNS:*[@id='#{ref}']//uosNS:exp:double-wrapper",
{"uosNS" => $http}).map {|element| element.text}
I am guessing that it would be easier to use .css here rather than
xpath. So I have tried using it but cannot seem to get it correct.
Trying -
ref = "i1574"
$doc_noko.css("uosNS|#{ref} uosNS|exp:double-wrapper", {"uosNS" =>
$http}).map {|element| element.text}
I read in a previous post that you call the ref using #{} for css,
but this returns nil for me.
Any ideas?