On Wed, Apr 20, 2011 at 5:54 PM, Kyle X. <haebooty / yahoo.com> wrote:
> Thank you for the reply Robert; however, I cannot get it to work still.
> I left out a lit bit of the xml when I wrote the first post. =A0Both case=
s
> have already have a namespace defined for them.
>
>
> Case 1) =A0These two lines would be added to both cases. =A0The actual fi=
le
> reads:
> <doc:iso_10303_28 xmlns:exp=3D"urn:oid:1.0.10303.28.2.1.1"
> xmlns:doc=3D"urn:oid:1.0.10303.28.2.1.3"
> xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation=3D"urn:oid:1.0.10303.28.2.1.1 ex.xsd" version=3D"2.0">
> =A0<uos id=3D"uos_1" description=3D"" configuration=3D"i-ifc2x3" edo=3D""
> xmlns=3D"http://www.iai-tech.org/ifcXML/IFC2x3/FINAL"
> xsi:schemaLocation=3D"http://www.iai-tech.org/ifcXML/IFC2x3/FINAL
> ifc2x3.xsd">
> =A0 =A0<IfcWallStandardCase id=3D"i17855">
> =A0 =A0 =A0<Representation>
> =A0 =A0 =A0 =A0<IfcProductDefinitionShape id=3D"i17925">
> =A0 =A0 =A0 =A0 =A0<Representations id=3D"i17928" exp:cType=3D"list">
> =A0 =A0 =A0 =A0 =A0 =A0<IfcShapeRepresentation exp:pos=3D"0" xsi:nil=3D"t=
rue"
> ref=3D"i17886"/>
> =A0 =A0 =A0 =A0 =A0 =A0<IfcShapeRepresentation exp:pos=3D"1" xsi:nil=3D"t=
rue"
> ref=3D"i17919"/>
> =A0 =A0 =A0 =A0 =A0</Representations>
> =A0 =A0 =A0 =A0</IfcProductDefinitionShape>
> =A0 =A0 =A0</Representation>
> =A0 =A0</IfcWallStandardCase>
> =A0</uos>
> </doc:iso_10303_28>
>
> The exact code I have been trying to run is:
>
> $http =3D "http://www.iai-tech.org/ifcXML/IFC2x3/FINAL"
> ref =3D "i17855"
> $doc_noko =3D Nokogiri::XML(File.read(filename))
>
> x =3D $doc_noko.xpath("//uosNS:*[@id=3D'#{ref}']//uosNS:*[@pos=3D'1']",
> {"uosNS" =3D> $http})
> #=3D> nil
>
> It reads for "//uosNS:*[@id=3D'#{ref}']" =A0but the "//uosNS:*[@pos=3D'1'=
]"
> is where it is not working as intended returning a nil value. =A0With
> these two new lines in mind any ideas for the two cases?

As I said: get rid of namespaces for wildcards.  Instead, of course
you have to add the NS for the attribute.  How you name your
namespaces in XPath expression doesn't really matter as long as the
_mapping_ is identical.  XML namespaces are just a convenient
replacement for the mapped URI.  So you need to make sure in the XPath
expression you use the same URI.

#!/bin/env ruby19

require 'nokogiri'

doc =3D Nokogiri.XML(DATA)

ref =3D "i17855"
puts doc.xpath("//*[@id=3D'#{ref}']//*[@uosNS:pos=3D'1']",
  {"uosNS" =3D> "urn:oid:1.0.10303.28.2.1.1"})


__END__
<doc:iso_10303_28 xmlns:exp=3D"urn:oid:1.0.10303.28.2.1.1"
  xmlns:doc=3D"urn:oid:1.0.10303.28.2.1.3"
  xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation=3D"urn:oid:1.0.10303.28.2.1.1 ex.xsd"
  version=3D"2.0">
 <uos id=3D"uos_1" description=3D"" configuration=3D"i-ifc2x3" edo=3D""
   xmlns=3D"http://www.iai-tech.org/ifcXML/IFC2x3/FINAL"
   xsi:schemaLocation=3D"http://www.iai-tech.org/ifcXML/IFC2x3/FINALifc2x3.=
xsd">
   <IfcWallStandardCase id=3D"i17855">
     <Representation>
       <IfcProductDefinitionShape id=3D"i17925">
         <Representations id=3D"i17928" exp:cType=3D"list">
           <IfcShapeRepresentation exp:pos=3D"0" xsi:nil=3D"true" ref=3D"i1=
7886"/>
           <IfcShapeRepresentation exp:pos=3D"1" xsi:nil=3D"true" ref=3D"i1=
7919"/>
         </Representations>
       </IfcProductDefinitionShape>
     </Representation>
   </IfcWallStandardCase>
 </uos>
</doc:iso_10303_28>

Cheers

robert


--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/