Using XPath 1.0, and given the following XML:
<Root>
<Line ID="1">
<Key>1</Key>
<Value>10001</Value>
</Line>
<Line ID="2">
<Key>2</Key>
<Value>10020</Value>
</Line>
<Line ID="3">
<Key>1</Key>
<Value>10300</Value>
</Line>
<Line ID="4">
<Key>2</Key>
<Value>14000</Value>
</Line>
</Root>
I need to be able to sum the values of all the lines that match the key of the "current" line being checked. So assuming the context is /Root/Line[2], then the sum should be 24020.
Unfortunately, using following/preceding sibling axes results in not being able to back reference the original "self" to predicate the key. Ex: following-sibling::Line[Key=./Key]/Value would return 10300 instead of 14000 because . is the current node on the sibling axes. I can't figure out how I would reference back to the original context?
Related
Is there any verb/action in Inkscape --shell mode to change/edit text in svg? I know I can do it in svg directly, but shell mode without temporary files seems cleaner to me.
BTW any chance of reading/writing files from/to stdin/stdout in shell mode? Same reason - avoid temp. files.
SVG file - critical part almost at the bottom - "text to edit"
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg1090"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
sodipodi:docname="drawing.svg">
<defs
id="defs1084" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.35"
inkscape:cx="400"
inkscape:cy="560"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1027"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1" />
<metadata
id="metadata1087">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<text
xml:space="preserve"
style="font-weight:bold;font-size:6.35px;line-height:1.25;font-family:Arial;-inkscape-font-specification:'Arial Bold';letter-spacing:0px;word-spacing:0px;stroke-width:0.264583"
x="42.333332"
y="46.113091"
id="text1655"><tspan
sodipodi:role="line"
id="tspan1653"
x="42.333332"
y="46.113091"
style="stroke-width:0.264583">text to edit</tspan></text>
</g>
</svg>
If you're after modifying the SVG with various different texts, try the https://gitlab.com/Moini/nextgenerator extension.
It should also be possible to run it standalone (never tried that, though).
I'm using a textPath and tspans to fit text into a svg path, and it works great in Chrome, but not so much in Edge and FF (o. Any help would be greatly appreciated
Here's a jsfiddle the svg node:
https://jsfiddle.net/ych9dr59/
And here's the relevant text code:
<text text-anchor="middle" font-size="8pt" font-family="Calibri" pointer-events="none">
<textPath xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#text_5_4_5_1590" startOffset="50%">
<tspan dy="-14pt">12): Maintain a</tspan>
</textPath>
<textPath xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#text_5_4_5_1590" startOffset="50%">
<tspan dy="8pt">policy that</tspan>
</textPath>
<textPath xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#text_5_4_5_1590" startOffset="50%">
<tspan dy="8pt">addresses</tspan>
</textPath>
<textPath xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#text_5_4_5_1590" startOffset="50%">
<tspan dy="8pt">information security</tspan>
</textPath>
<textPath xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#text_5_4_5_1590" startOffset="50%">
<tspan dy="8pt">for all personnel. </tspan>
</textPath>
</text>
SVG text element is pretty buggy in general in my experience. My recommendation for maximum cross-browser sanity would be to use a separate text element for each text fragment and use normal x/y positioning and a transform/rotate to render your text.
Firefox is actually rendering correctly. According to the 1.1 spec, the start of each new textPath should be an absolute reset of the current text position. You should manually adjust the dy offsets of the tspans so they're cumulative (instead of 8pt in ever one, it should be 8pt, 16pt, 24pt). So it's actually a Chrome bug that your stuff works in the first place.
Edge only seems to support a single textPath element per text element, so you do need to wrap each textPath in its own text element.
I've created a 3D bar in illustrator (see codepen). Now I want to animate it with TweenMax (or TimelineMax) as if it's building up from the bottom to the top.
This is the end result what I need to create:
http://postimg.org/image/pg2drnvch/
I tried a couple of things to make this happen, but without any luck.
Created a clipping-path and then try to change the Y coordinate of the 3 polygons (or wrapped them in a < g >< /g >)
Tried to animate the points of the polygon (http://greensock.com...ing-attrplugin/)
I hope someone can help me with this.
Codepen URL: http://codepen.io/boldcolin/pen/rOPPgP
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="bar_1_" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
width="140.5px" height="366.7px" viewBox="0 0 140.5 366.7" style="enable-background:new 0 0 140.5 366.7;" xml:space="preserve"
>
<style type="text/css">
.st0{clip-path:url(#SVGID_2_);fill:#8BBE3F;}
.st1{clip-path:url(#SVGID_2_);fill:#81A83F;}
.st2{clip-path:url(#SVGID_2_);fill:#A1C63C;}
</style>
<g>
<defs>
<polygon id="SVGID_1_" points="80.3,0 0,40.1 0,336.7 60.2,366.7 140.5,327.1 140.5,30.7 "/>
</defs>
<clipPath id="SVGID_2_">
<use xlink:href="#SVGID_1_" style="overflow:visible;"/>
</clipPath>
<polygon class="st0" points="140.7,169.4 0.2,178.9 0.2,350.2 60.4,380.1 140.7,340.6 "/>
<polyline class="st1" points="60.4,380.1 60.4,205.9 0.2,178.9 0.2,350.2 "/>
<polygon class="st2" points="0.2,178.9 80.5,138.7 140.7,169.4 60.4,209 "/>
</g>
This is an example: http://boldinteractive.nl/raet/bar/
Here I used a white layer on top of the bar which acts like a faux mask. But this is not how I want to make this work..
It's seems impossible to mask a polygon with a polygon and then animate the shape. I'm now using a path (in Illustrator use 'make compound path') and then use this as clipping mask.
This is my first time asking a question so I'll try my best to include all the necessary information.
I am currently working on a machine learning project using PyBrain. My aim is for a driven pendulum to learn when force should be applied to maximise the amplitude of oscillation.
To do this, I have modelled the system in ODE (Open Dynamics Engine) using the xodetools.py script that is included with PyBrain. While the model works and is simulated, I cannot figure out how to add friction to the pendulum hinge joint.
Some of the example models included with Pybrain (e.g. johnnie_pgpe) redefine a paramater called FricMu in their Task class. I have included this in my code, but no matter what value I set FricMu equal to the system is unchanged (note: if I make it a string the simulation still runs so I presume this parameter is actually doing nothing).
A quick look at the ODE documentation (http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions#Contact) suggests to me that I need to be using a contact joint. This type of joint is not supported by the script so I think would require me to write direct to the XML file.
Can someone with an understanding of either PyBrain or ODE give me some advice on how to increase the damping of my system. Thank you.
Below is the XML code for the pendulum that is imported by PyBrain
<?xml version="1.0" encoding="UTF-8"?>
<xode version="1.0r23" name="pend"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://tanksoftware.com/xode/1.0r23/xode.xsd">
<world>
<space>
<body name="arm">
<transform>
<position y="0" x="0" z="0"/>
</transform>
<mass>
<mass_shape density="125.0">
<box sizex="0.2" sizez="0.2" sizey="0.2"/>
</mass_shape>
</mass>
<geom>
<box sizex="0.2" sizez="0.2" sizey="0.2"/>
</geom>
</body>
<body name="swing">
<transform>
<position y="0" x="0" z="2.2"/>
<rotation>
<euler y="0" x="0" aformat="degrees" z="0"/>
</rotation>
</transform>
<mass>
<mass_shape density="6.36619772588">
<cylinder length="5" radius="0.05"/>
</mass_shape>
</mass>
<geom>
<cylinder length="5" radius="0.05"/>
</geom>
</body>
<joint name="arm_swing">
<link1 body="arm"/>
<link2 body="swing"/>
<hinge>
<axis y="0" x="1" z="0"/>
<anchor y="0" x="0" z="0" absolute="true"/>
</hinge>
</joint>
<joint name="fixedPoint">
<link1 body="arm"/>
<link2 body="swing"/>
<fixed>
</fixed>
</joint>
<geom name="floor">
<plane a="0" c="0" b="1" d="-44.0"/>
</geom>
</space>
</world>
</xode>
<!--odeenvironment parameters
<passpairs>
('arm', 'swing')
<affixToEnvironment>
fixedPoint
<end>
-->
everyone!
Please help me to solve a problem. I have the following svg:
<div style="height: 1257px; width: 728px;">
<svg viewPort="0 0 728 1257" xmlns="http://www.w3.org/2000/svg">
<line stroke="black" stroke-width="2" y2="100" x2="100" y1="100" x1="20"/>
<line stroke="black" stroke-width="2" y2="150" x2="200" y1="154" x1="504"/>
<line y2="353" x2="504" y1="459" x1="388" style="stroke:rgb(255,0,0);stroke-width:2"/>
<line y2="353" x2="504" y1="400" x1="1141" style="stroke:rgb(255,0,0);stroke-width:2"/>
<line y2="197" x2="602" y1="353" x1="504" style="stroke:rgb(255,0,0);stroke-width:2"/>
<line y2="371" x2="957" y1="274" x1="749" style="stroke:rgb(255,0,0);stroke-width:2"/>
<line y2="192" x2="1079" y1="371" x1="957" style="stroke:rgb(255,0,0);stroke-width:2"/>
</svg>
</div>
Please, check it in the FF: http://jsfiddle.net/SgAA5/.
It contains 7 lines inside. I can see it correctly in all browsers except Firefox. Whats wrong with this svg? I trying to draw lines through different ways, but I see only following in the FF:
Just one line, and the part of another one. Looks like only small area available to draw. Any ideas?
Oh, I've found solution on stackoverflow :) Inline SVG with transforms not visible in Firefox, works fine in Chrome
It depends on tag parameters.
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%">
is right way