Ability to validate xml on xsd using Objc / iPhone code at runtime

I have xml files that I read at runtime, is it possible to check the xsd xml file at runtime using Obj C ?? This can be done in java and c # . But I need to complete this time in my iphone application.

+5
source share
3 answers
+6
source

CodeSynthesis XSD/e iPhone ( Mac)


# 1:

XSD/e (libxsde.a), :

  • XSD/e Mac OS X.

  • :

    cd xsde-3.2.0-i686-macosx

    cp etc/ios/config-xcode.make config/config.make

    .

  • config/config.make XSD/e .

  • :

    cd libxsde

    make

    make , /Developer/usr/bin/make ( XCode).

  • XCode :

    5.1 "" → " "

    5.2 "iOS Library" → "Cocoa Touch Static   ". "...".

    5.3 libxsde " "    xsde-3.2.0-i686-macosx. "".

    5.4 , libxsde    . , "".

    5.5 " " "   ", "" → " ...".

    5.6 xsde-3.2.0-i686-macosx/libxsde    src. "".

    5.7 "".    (.cxx .c),    " ".

    5.8 "" → " ", "".    "" " ".

    5.9 " " . ()    " ".

    5.10 "GCC 4.2 - Language"    -fvisibility = "Other C Flags"     -fvisibility = -fvisibility-inlines-     " ++". C/++     , .

    5.11 (,    Debug/Release, Device/Simulator, ARMv6/ARMv7 ..).

  • "" , (, , ):

    cd build

    lipo -output libxsde.a -create Release-iphonesimulator/liblibxsde.a Release-iphoneos/liblibxsde.a

    lipo -output libxsde-d.a -create Debug-iphonesimulator/liblibxsde.a Debug-iphoneos/liblibxsde.a

- XSD/e, ( 1 ), XCode .

XSD/e :

  • ++ XSD/e (xsde-3.2.0-i686-macosx/bin/xsde) ++ .

  • XSD/e (libxsde), :

    2.1 "" ,    "".

    2.2 "" "" (+),   .

    2.3 " ..."    libxsde.a libxsde-d.a(debug), .

  • XSD/e , :

    3.1 "" → " ", "".    "" " ".

    3.2 " "   xsde-3.2.0-i686-macosx/libxsde " ".

    3.3. .

+1

objC Api iOS sdks. API- libxml C.

  • you are loading xml (e.g. xmlReadMemory)
  • then for XSD you should use xmlSchemaValidateDoc

or you can use the following wrapper class [disclaimer: I'm author]:
DDXMLValidator (part of my helpers @ https://github.com/Daij-Djan/DDUtils/ )

//validate
NSError *error = nil;
NSURL *schemaURL = [[NSBundle mainBundle] URLForResource:@"XMLSchema" withExtension:@"xsd"];
if(![[SNXMLValidator sharedInstace] validateXMLData:xmlData withSchema:SNXMLValidatorSchemaTypeXSD schemaFile:schemaURL error:&error]) {
    DebugLog(@"Failed to validate data: %@", error);
}

the class can do DTD, XSD, RelaxNG (it just wraps libxml2)

+1
source

All Articles