I have several XML documents that have different amount of names under images on each page. It can be one name or it could be 50. how can I insert this into a SQL database?
This is a snippet of the XML, so under images there is a name is this there are 2, but the next XML could have 10. the info inside of name is the same every time. How do I insert into SQL when these can be different any or every time?
-
-
1073073r1Prepress_step_CDI-SDDC_DRed_1.len
49.9429
21.7758
2400.0
1087.549
1
1
51.1929
23.0258
1178.76
"./images/7-17-14_Flat_1_FRC250Conv/1073073r1Prepress_step_CDI-SDDC_DRed_1__.len.gif"
-
1070635r0Prepress_step_CDI-SD_K_1.len
27.4746
6.7833
2400.0
186.369
1
1
29.6695
8.9782
266.379
"./images/7-17-14_Flat_1_FRC250Conv/1070635r0Prepress_step_CDI-SD_K_1__.len.gif"
-<Name>
1073073r1Prepress_step_CDI-SDDC_DRed_1.len
<Width unit="inch">49.9429</Width>
<Height unit="inch">21.7758</Height>
<Resolution unit="DPI">2400.0</Resolution>
<Area unit="sq in">1087.549</Area>
<X-Repeat>1</X-Repeat>
<Y-Repeat>1</Y-Repeat>
<Used_Width unit="inch">51.1929</Used_Width>
<Used_Height unit="inch">23.0258</Used_Height>
<TotalArea unit="sq in">1178.76</TotalArea>
<GIF-IMAGE> "./images/7-17-14_Flat_1_FRC250Conv/1073073r1Prepress_step_CDI- SDDC_DRed_1__.len.gif" </GIF-IMAGE>
</Name>
-<Name>
1070635r0Prepress_step_CDI-SD_K_1.len
<Width unit="inch">27.4746</Width>
<Height unit="inch">6.7833</Height>
<Resolution unit="DPI">2400.0</Resolution>
<Area unit="sq in">186.369</Area>
<X-Repeat>1</X-Repeat>
<Y-Repeat>1</Y-Repeat>
<Used_Width unit="inch">29.6695</Used_Width>
<Used_Height unit="inch">8.9782</Used_Height>
<TotalArea unit="sq in">266.379</TotalArea>
<GIF-IMAGE> "./images/7-17-14_Flat_1_FRC250Conv/1070635r0Prepress_step_CDI-SD_K_1__.len.gif" </GIF-IMAGE>
</Name>
Related
I want to read the data from passage_para tag, after passage_para I have 2 spaces before the expression tag and after the expression tag I have one more space, etc. When I use extract function to get the passage_para tag from the XMLTYPE column it is eliminating all the spaces.
<?xml version="1.0" encoding="UTF-8"?> <item> <information number="sdjsadh" > <response_direction delivery_mode="xcs"> <dparagraph>test</dparagraph> </response_direction> </information> <i_content> <stimulus_reference> <passage> <prose style="1"> <passage_para> <expression> <math xmlns="Math" xmlns:xlink="xlink" display="inline" overflow="scroll"> <mr> <mi>z</mi> <mo>></mo> <mn>0</mn> </mr> </math> </expression> </passage_para> </prose> </passage> </stimulus_reference> </i_content> </item>
which I don't want because it is taking out the spaces. The desired output I need is " z > 0 ".
Note: Between the passage_para tag the child nodes may change, they are not going to be the same.
I am new to xpath. I am trying to use the "nuPickers XML Dropdown picker" on Umbraco 7.3.4
but no matter what xpath xpression filter i use, the dropdown remains empty no nodes is being loaded in to the dropdown
i tried the following filters:
$root/
$site/
/*/
$ancestor-or-self::Home/
but to no avail, none of them loads any nodes
i actually want to select all the "Club" nodes under "Clubcontainer", but i cant get it to load any nodes, nevermind the specific ones that i actually want. My Umbraco.config looks as follows: (some nodes removed under to only show relevant nodes for my filter query.)
<root id="-1">
<Home id="2081" key="ebb9222f-f26c-4462-9f5d-43dba520326f" parentID="-1" level="1" creatorID="0" sortOrder="0" createDate="2015-12-29T12:19:53" updateDate="2016-01-09T17:27:57" nodeName="Home" urlName="home" path="-1,2081" isDoc="" nodeType="1070" creatorName="Gerrie Pretorius" writerName="Gerrie Pretorius" writerID="0" template="1049" nodeTypeAlias="Home">
<Clubcontainer id="2094" key="6f11e986-3e29-4555-8bc4-5a847600704c" parentID="2081" level="2" creatorID="0" sortOrder="3" createDate="2015-12-29T13:20:15" updateDate="2016-01-09T17:27:57" nodeName="Chess Clubs" urlName="chess-clubs" path="-1,2081,2094" isDoc="" nodeType="2092" creatorName="Gerrie Pretorius" writerName="Gerrie Pretorius" writerID="0" template="0" nodeTypeAlias="Clubcontainer">
<Club id="2103" key="856c9937-cf4c-481b-aaba-487e0dcee199" parentID="2094" level="3" creatorID="0" sortOrder="0" createDate="2016-01-07T22:41:28" updateDate="2016-01-09T17:27:57" nodeName="Hlalefang Alexandra Chess club" urlName="hlalefang-alexandra-chess-club" path="-1,2081,2094,2103" isDoc="" nodeType="2093" creatorName="Gerrie Pretorius" writerName="Gerrie Pretorius" writerID="0" template="0" nodeTypeAlias="Club">
<president><![CDATA[Mr President]]></president>
<presidentCell><![CDATA[0123 13131313]]></presidentCell>
<presidentEmail><![CDATA[johnDoe#example.net]]></presidentEmail>
</Club>
<Club id="2104" key="a5d73286-9572-445b-9d3a-7f758de64d0e" parentID="2094" level="3" creatorID="0" sortOrder="1" createDate="2016-01-07T22:42:27" updateDate="2016-01-09T17:27:57" nodeName="Chess Excellence" urlName="chess-excellence" path="-1,2081,2094,2104" isDoc="" nodeType="2093" creatorName="Gerrie Pretorius" writerName="Gerrie Pretorius" writerID="0" template="0" nodeTypeAlias="Club">
<president><![CDATA[Jane Doe]]></president>
<presidentCell><![CDATA[012 345 6789]]></presidentCell>
<webAddress><![CDATA[http://www.example.net]]></webAddress>
<presidentEmail><![CDATA[janedoe#example.net]]></presidentEmail>
</Club>
</Clubcontainer>
</Home>
</root>
If some-one can help me witht his i would greatly appreciate it.
Found the answer provided to me by Marc Goodson here
To load all Nodes of documentType Club use //Club
or to load the specific club nodes:
$ancestorOrSelf/ancestor-or-self::Home[position()=1]//Clubcontainer//Club
I have a XML file which contains multiple XML nodes. I would like to separate two XML notes and store them in separate variables. How would I write this functionality with XQuery? I have added my XML file below. Inside the XML file I have a division root element, Dive and top-song are two child elements. Now I want to read the Dive XML content in one variable and top-song content in another variable. Can any one please help me to sort out this issue?
<?xml version="1.0" encoding="UTF-8"?>
<division>
<Dive ID="2"><!-- I want this node in one variable -->
<DiverFName>Joe</DiverFName>
<DiverLName>Diver</DiverLName>
<Number>2</Number>
<Divedate>1998-03-30</Divedate>
<Country ID="1">Bahamas</Country>
<City ID="2">Freeport</City>
<Place ID="2">
<Site>South Pass</Site>
<Lat>24.865062</Lat>
<Lon>-77.871094</Lon>
</Place>
<Divetime>36.00</Divetime>
<Depth Scale="METRIC">5.48</Depth>
<Buddy IDs="2" Names="Tim Diver" />
<Comments>Great dive, saw 5 Caribbean Reef Sharks. Performed compass navigation skills for Scuba Diver certification.</Comments>
<Water>Salt</Water>
<Entry>Boat</Entry>
<Divetype>Research</Divetype>
<Tanktype>Alu</Tanktype>
<Tanksize>11.43</Tanksize>
<PresS>179.26</PresS>
<PresE>82.73</PresE>
<Gas>Air</Gas>
<Weather>Clear</Weather>
<UWCurrent>Medium Current</UWCurrent>
<MarineLife>
<Animal>
<Type>Nurse Shark</Type>
<Abundance>1</Abundance>
<Size>3 ft</Size>
<Description>Dormant on the bottom, not swimming.</Description>
<Image>
<Filename></Filename>
<Path></Path>
<Caption></Caption>
</Image>
</Animal>
<Animal>
<Type>Blue Tang Surgeonfish</Type>
<Abundance>25+</Abundance>
<Size>4 in</Size>
<Description>Blue with white "scalpel" near base </descreption>
<Image>
<Filename></Filename>
<Path></Path>
<Caption></Caption>
</Image>
</Animal>
</MarineLife>
</Dive>
<top-song><!-- I want this node in another variable -->
<title >Try Again</title>
<artist >Aaliyah</artist>
<weeks last="2008-06-17">
<week>2008-06-17</week>
</weeks>
<album> The
Album</album>
<released>February 29, 20008</released>
<formats>
<format>CD</format>
<format>12 single</format>
</formats>
<recorded>january2012</recorded>
<genres>
<genre>R&B</genre>
</genres>
<lengths>
<length>4:04</length>
</lengths>
<label>Blackground</label>
<writers>
<writer></writer>
<writer></writer>
</writers>
<producers>
<producer></producer>
</producers>
<descr>
<p>hai hello</p>
</descr>
</top-song>
</division>
It's not clear what you're trying to accomplish on a high level, but you can select those elements with some simple XQuery/Xpath:
let $dive := doc('mydoc.xml')/division/Dive
let $top-song := doc('mydoc.xml')/division/top-song
However, just looking at the document it's clear that these two elements are in totally unrelated schemas, and as a general recommendation for MarkLogic, they should probably each be separated before ingestion and inserted as separate documents.
I have a small xml file that I'm trying to grab the away_team first and then the home_team second.
/game/team/statistics/#goals gives me the data I want but I need to reverse the order. So I'm trying to understand how to get the away_team goals first, followed by the home_team.
Below is the file
<game id="f24275a9-4f30-4a81-abdf-d16a9aeda087" status="closed" coverage="full" home_team="4416d559-0f24-11e2-8525-18a905767e44" away_team="44167db4-0f24-11e2-8525-18a905767e44" scheduled="2013-10-10T23:00:00+00:00" attendance="18210" start_time="2013-10-10T23:08:00+00:00" end_time="2013-10-11T01:32:00+00:00" clock="00:00" period="3" xmlns="http://feed.elasticstats.com/schema/hockey/game-v2.0.xsd">
<venue id="bd7b42fa-19bb-4b91-8615-214ccc3ff987" name="First Niagara Center" capacity="18690" address="One Seymour H. Knox III Plaza" city="Buffalo" state="NY" zip="14203" country="USA"/>
<team name="Sabres" market="Buffalo" id="4416d559-0f24-11e2-8525-18a905767e44" points="1">
<scoring>
<period number="1" sequence="1" points="1"/>
<period number="2" sequence="2" points="0"/>
<period number="3" sequence="3" points="0"/>
</scoring>
<statistics goals="1" assists="2" penalties="7" penalty_minutes="23" team_penalties="0" team_penalty_minutes="0" shots="27" blocked_att="14" missed_shots="8" hits="25" giveaways="5" takeaways="10" blocked_shots="7" faceoffs_won="22" faceoffs_lost="28" powerplays="1" faceoffs="50" faceoff_win_pct="44.0" shooting_pct="3.7" points="3">
<powerplay faceoffs_won="2" faceoffs_lost="0" shots="0" goals="0" missed_shots="1" assists="0" faceoff_win_pct="100.0" faceoffs="2"/>
<shorthanded faceoffs_won="3" faceoffs_lost="3" shots="1" goals="0" missed_shots="0" assists="0" faceoffs="6" faceoff_win_pct="50.0"/>
<evenstrength faceoff_win_pct="40.5" missed_shots="7" goals="1" faceoffs_won="17" shots="26" faceoffs="42" faceoffs_lost="25" assists="2"/>
<penalty shots="0" goals="0" missed_shots="0"/>
</statistics>
<shootout shots="0" missed_shots="0" goals="0" shots_against="0" goals_against="0" saves="0" saves_pct="0"/>
<goaltending shots_against="33" goals_against="4" saves="29" saves_pct="0.879" total_shots_against="33" total_goals_against="4">
<powerplay shots_against="0" goals_against="0" saves="0" saves_pct="0"/>
<shorthanded shots_against="7" goals_against="0" saves="7" saves_pct="1.0"/>
<evenstrength goals_against="4" saves_pct="0.846" shots_against="26" saves="22"/>
<penalty shots_against="0" goals_against="0" saves="0" saves_pct="0"/>
<emptynet goals_against="0" shots_against="0">
<powerplay goals_against="0"/>
<shorthanded goals_against="0"/>
<evenstrength goals_against="0"/>
</emptynet>
</goaltending>
Here's an XPath 2.0 expression that should do what you asked, yielding a sequence of two elements:
(/game/team[#id = /game/#home_team]/statistics/#goals,
/game/team[#id = /game/#away_team]/statistics/#goals)
Credit to #Ian for sleuthing out the details of the question.
In XPath 1.0, you could concatenate string data from the two teams in whatever order you want:
concat(/game/team[#id = /game/#home_team]/statistics/#goals, ' ',
/game/team[#id = /game/#away_team]/statistics/#goals)
But as Ian said, you can't produce a nodeset with an order different from document order. (I don't think a nodeset has any intrinsic order at all... it's how it's processed that imposes an order.)
Update:
As Ian pointed out, your XML data is in a namespace, thanks to the default namespace declaration on <game>. Since you said that "/game/team/statistics/#goals gives me the data", I'm assuming that you've already taken care of this aspect of the problem, perhaps by declaring the default namespace in your XPath execution environment.
I have a tavle storing photos. With a pl/sql script i extract the image metadata to the exifmetadata xmltype column.
I would like to select the elements one by one, but i always get null back and i don't know what is the issue with my xpath expression.
<exifMetadata xmlns="http://xmlns.oracle.com/ord/meta/exif" xsi:schemaLocation="http://xmlns.oracle.com/ord/meta/exif http://xmlns.oracle.com/ord/meta/exif" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<TiffIfd>
<Make tag="271">Apple</Make>
<Model tag="272">iPhone 4S</Model>
<Orientation tag="274">top left</Orientation>
<XResolution tag="282">72.0</XResolution>
<YResolution tag="283">72.0</YResolution>
<ResolutionUnit tag="296">inches</ResolutionUnit>
<Software tag="305">6.0.1</Software>
<DateTime tag="306">2012-11-16T13:31:15</DateTime>
<YCbCrPositioning tag="531">centered</YCbCrPositioning>
</TiffIfd>
<ExifIfd tag="34665">
<ExposureTime tag="33434">0.004405286</ExposureTime>
<FNumber tag="33437">2.4</FNumber>
<ExposureProgram tag="34850">Normal program</ExposureProgram>
<ExifVersion tag="36864">0221</ExifVersion>
<DateTimeOriginal tag="36867">2012-11-16T12:49:58</DateTimeOriginal>
<DateTimeDigitized tag="36868">2012-11-16T12:49:58</DateTimeDigitized>
<ComponentsConfiguration tag="37121">Y</ComponentsConfiguration>
<ShutterSpeedValue tag="37377">7.82697</ShutterSpeedValue>
<ApertureValue tag="37378">2.5260692</ApertureValue>
<BrightnessValue tag="37379">6.641153</BrightnessValue>
<MeteringMode tag="37383">Pattern</MeteringMode>
<Flash tag="37385">
<Fired>No</Fired>
</Flash>
<FocalLength tag="37386">4.28</FocalLength>
<FlashpixVersion tag="40960">0100</FlashpixVersion>
<ColorSpace tag="40961">sRGB</ColorSpace>
<PixelXDimension tag="40962">2902</PixelXDimension>
<PixelYDimension tag="40963">1938</PixelYDimension>
<SensingMethod tag="41495">One-chip color area</SensingMethod>
<ExposureMode tag="41986">Auto exposure</ExposureMode>
<WhiteBalance tag="41987">Auto</WhiteBalance>
<FocalLengthIn35mmFilm tag="41989">35</FocalLengthIn35mmFilm>
<SceneCaptureType tag="41990">Standard</SceneCaptureType>
</ExifIfd>
</exifMetadata>
And the SQL:
SELECT
p.metaexif.extract('//exifMetadata/TiffIfd/Make/text()').getStringVal() "Model"
FROM scott.photos p
WHERE id=22
;
The id 22 record exist that is sure.
you have a default namespace set so you have to cope with this.
eg use this:
select extractvalue(p.metaexif,'/exifMetadata/TiffIfd/Make',
'xmlns="http://xmlns.oracle.com/ord/meta/exif"')