Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Squinty Applebottom
Jan 1, 2013

artisanal hand crafted xml

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

dur posted:

i'm a bad programmer. this is how i'm making an xml file in python

Python code:
fcline = '\t<FeatureClass name=\"%s\" oid_field=\"ObjectID\">\n'
fline = '\t\t<Feature oid=\"%s\" action=\"added\" />\n'

outFile.write(fcline % 'MISC_PLAN_METRICS')
for row in arcpy.SearchCursor('MISC_PLAN_METRICS_Work'):
	outFile.write(fline % row.ObjectID)
outFile.write('\t</FeatureClass>\n')
	
outFile.write(fcline % 'Park_Boundaries')
for row in arcpy.SearchCursor('Park_Boundaries_Work'):
	outFile.write(fline % row.ObjectID)
outFile.write('\t</FeatureClass>\n')

outFile.write(fcline % 'Hydrology')
for row in arcpy.SearchCursor('Hydrology_Work'):
	outFile.write(fline % row.ObjectID)
outFile.write('\t</FeatureClass>\n')
it works though

my boss did this. he then fixed it by writing another program to read the broken html and try and escape the text he'd forgotten

if you can't be arsed to find a library to write xml, at least escape the goddam values you put in i.e

code:
from xml.sax.saxutils import escape, quoteattr

def fline(obj_id):
    return '\t\t<Feature oid=\"%s\" action=\"added\" />\n' % quoteattr(obj_id)

...
    outFile.write(fline(row.ObjectID))
future you will thank you for making some effort.

Bloody
Mar 3, 2013

just use a lang with xml literals and hail satan

Shaggar
Apr 26, 2006
just use jaxb to serialize the objects directly.

Elder Postsman
Aug 30, 2000


i used hot bot to search for "teens"

tef posted:

my boss did this. he then fixed it by writing another program to read the broken html and try and escape the text he'd forgotten
idk, my poo poo code outputs xml that can be read by the program i need to it be read by

XML code:
	<FeatureClass name="MISC_PLAN_METRICS" oid_field="ObjectID">
		<Feature oid="10299" action="added" />
		<Feature oid="10300" action="added" />
		<Feature oid="20696" action="added" />
		<Feature oid="49189" action="added" />
		<Feature oid="49242" action="added" />
		<Feature oid="49260" action="added" />
	</FeatureClass>

quote:

if you can't be arsed to find a library to write xml, at least escape the goddam values you put in i.e

code:
from xml.sax.saxutils import escape, quoteattr

def fline(obj_id):
    return '\t\t<Feature oid=\"%s\" action=\"added\" />\n' % quoteattr(obj_id)

...
    outFile.write(fline(row.ObjectID))
future you will thank you for making some effort.
probably not on this particular script because this is a thing i'm gonna use once and then be done with. but it is good to know better ways to do it. thank you!

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band
just found out there's a team somewhere around here that uses erlang. yet i can't get free of this ancient stinking pile of vbscript :smithicide:

tef
May 30, 2004

-> some l-system crap ->
use wasabi

Share Bear
Apr 27, 2004

tef posted:

use wasabi

i just looked up what that is. holy poo poo

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
i just made a thing that exports excel spreadsheets by creating an excel template where I put !!H1!! !!H2!!...etc in every cell and then doing a sed in sharedStrings.xml for those keywords.

way easier than figuring out the xlsx formatting poo poo

PleasingFungus
Oct 10, 2012
idiot asshole bitch who should fuck off

Share Bear posted:

i just looked up what that is. holy poo poo

quote:

No single programming language exists that does all the things that typically require four. You need a server language (In FB5 this was ASP and PHP), a client language (probably JS), a content language (HTML), and a formatting language (CSS).

10 paragraphs of a lovely hacked-together cross-lingual PHP/ASP code generation system, and then this

wonderful

tef
May 30, 2004

-> some l-system crap ->
protocoffeescript

NOTinuyasha
Oct 17, 2006

 
The Great Twist

dur posted:

i'm a bad programmer. this is how i'm making an xml file in python

Python code:
fcline = '\t<FeatureClass name=\"%s\" oid_field=\"ObjectID\">\n'
fline = '\t\t<Feature oid=\"%s\" action=\"added\" />\n'

outFile.write(fcline % 'MISC_PLAN_METRICS')
for row in arcpy.SearchCursor('MISC_PLAN_METRICS_Work'):
	outFile.write(fline % row.ObjectID)
outFile.write('\t</FeatureClass>\n')
	
outFile.write(fcline % 'Park_Boundaries')
for row in arcpy.SearchCursor('Park_Boundaries_Work'):
	outFile.write(fline % row.ObjectID)
outFile.write('\t</FeatureClass>\n')

outFile.write(fcline % 'Hydrology')
for row in arcpy.SearchCursor('Hydrology_Work'):
	outFile.write(fline % row.ObjectID)
outFile.write('\t</FeatureClass>\n')
it works though

what you actually are is a really really bad programmer, im a regular bad programmer and it only took me like five minutes to figure out lxml

NOTinuyasha
Oct 17, 2006

 
The Great Twist
i had to generate something with a custom namespace once and i just used a template engine because it would have required actually reading the documentation to do it in lxml, but that one case was acceptable because i checked on github and found a real programmer who did it too.

Nomnom Cookie
Aug 30, 2009



Shaggar posted:

just use jaxb to serialize the objects directly.

does jaxb do like jackson where you give it pojos w/o annotations or anything and it can figure out the right thing to do

Shaggar
Apr 26, 2006
actually idk. I know cxf can automatically serialize stuff w/out annotations but idk if it adds them itself before passing it off to jaxb or if jaxb is smart enough to figure it out w/out them

cliffy
Apr 12, 2002

just say no to xml

uG
Apr 23, 2003

by Ralp
just use json

PleasingFungus
Oct 10, 2012
idiot asshole bitch who should fuck off

NOTinuyasha posted:

what you actually are is a really really bad programmer, im a regular bad programmer and it only took me like five minutes to figure out lxml

quote:

I don't think I've ever seen you post something constructive or helpful. User loses posting privileges for 3 days. Louisgod angerbot

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
every time i get probated (a lot), i secretly feel kinda bad about it (once or twice ifelt really bad because i definitely deserved it). if anyone ever commented on or cared about it i think it would suck a lot more than i'd ever admit

~Coxy
Dec 9, 2003

R.I.P. Inter-OS Sass - b.2000AD d.2003AD

dur posted:

i'm a bad programmer. this is how i'm making an xml file in python

Python code:
fcline = '\t<FeatureClass name=\"%s\" oid_field=\"ObjectID\">\n'
fline = '\t\t<Feature oid=\"%s\" action=\"added\" />\n'

outFile.write(fcline % 'MISC_PLAN_METRICS')
for row in arcpy.SearchCursor('MISC_PLAN_METRICS_Work'):
	outFile.write(fline % row.ObjectID)
outFile.write('\t</FeatureClass>\n')
	
outFile.write(fcline % 'Park_Boundaries')
for row in arcpy.SearchCursor('Park_Boundaries_Work'):
	outFile.write(fline % row.ObjectID)
outFile.write('\t</FeatureClass>\n')

outFile.write(fcline % 'Hydrology')
for row in arcpy.SearchCursor('Hydrology_Work'):
	outFile.write(fline % row.ObjectID)
outFile.write('\t</FeatureClass>\n')
it works though

had to do something like that to call a WCF service from a VBA script, condolences

btw members in a SOAP object better be in alphabetical order so have fun reordering your text strings every time something changes

Doc Block
Apr 15, 2003
Fun Shoe

chumpchous posted:

every time i get probated (a lot), i secretly feel kinda bad about it (once or twice ifelt really bad because i definitely deserved it). if anyone ever commented on or cared about it i think it would suck a lot more than i'd ever admit

you were pretty much asking for it with the maggots in noses videos you linked to.

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

chumpchous posted:

every time i get probated (a lot), i secretly feel kinda bad about it (once or twice ifelt really bad because i definitely deserved it). if anyone ever commented on or cared about it i think it would suck a lot more than i'd ever admit

i feel really bad when i get probated; i always send an apology pm to the mod that had to deal with me :smith:

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band
can anybody recommend a good primer/tutorial/reference/explanation of dot-net web services using c# and visual studio? i'm about to try to assemble a web service (or two; not sure if they should be two separate things), and i'm hoping i can find a guide to common approaches to use and common traps to look out for

thanks much

CamH
Apr 11, 2008

just create a new project in visual studio and go for it. it's literally that easy

uG
Apr 23, 2003

by Ralp
if you're using c# for web services you've already sprung the trap

CamH
Apr 11, 2008

C# is the best language sorry for your lots

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

uG posted:

if you're using c# for web services you've already sprung the trap

it's what they all use around here; i've tried multiple times to get other things into the ecosystem, but it's time to just give up and go with the flow :smith:

Shaggar
Apr 26, 2006
WCF is pretty easy to use. The default service created by visual studio when you create a wcf service application is a basic example that's kind of useful.

As with java and CXF you define the service using an interface and model objects and then you tie an implementation to the interface at runtime.

The easiest way to get started is just to modify the existing service interface (IService) and play around w/ it and the implementation.

Shaggar
Apr 26, 2006

CamH posted:

just create a new project in visual studio and go for it. it's literally that easy

yeah its literally this

Shaggar
Apr 26, 2006

CamH posted:

C# is the best language sorry for your lots

also this

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

Shaggar posted:

yeah its literally this

it's (another) personality flaw of mine that i'm usually too terrified to do anything without first doing research and trying to learn about it and so on and so forth

uG
Apr 23, 2003

by Ralp
just embed your fav p-lang in your project and script ur way to the bank

tef
May 30, 2004

-> some l-system crap ->
https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/ConnectionStatus.java#L213

CamH
Apr 11, 2008

shaggar and I agree on something. lets make out in your Taurus after work, shaggar

Shaggar
Apr 26, 2006
it has a spacious back seat that will be perfect

coaxmetal
Oct 21, 2010

I flamed me own dad
https://github.com/dcramer/mangodb

Shaggar
Apr 26, 2006

anyone using mongo deserves what they get

Shark Sandwich
Sep 6, 2010

by R. Guyovich
every few months a recruiter from 10gen sends me a linkedin message about all the exciting opportunities to work on mongodb and i have a good chuckle

Sharktopus
Aug 9, 2006

Adbot
ADBOT LOVES YOU

coaxmetal
Oct 21, 2010

I flamed me own dad

  • Locked thread