XmlTransform validate on parse

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • seigo

    XmlTransform validate on parse

    Hi there,

    I use the following code to transform xml to html document:

    try
    {
    XPathDocument myXPathDoc = new XPathDocument(s XmlPath);
    XslTransform myXslTrans = new XslTransform();
    myXslTrans.Load (sXslPath);

    //create the output stream
    XmlTextWriter myWriter = new XmlTextWriter(" result.html", null);

    //do the actual transform of Xml

    myXslTrans.Tran sform(myXPathDo c, null, myWriter, null);

    myWriter.Close( );
    }
    catch(Exception e)
    {
    Console.WriteLi ne("Exception: {0}", e.ToString());
    }

    Xml document contains the following namespace:

    <Primetime_Scre ening
    xmlns="http://www.medicalhist ory.com/PrimetimeScreen ing" ..>

    When this namespace exists there is no data from xml document. And
    after I remove such xmlns transformation works fine. I think something
    with validation. If I am right how to disable validation during xml
    transformation or maybe it's better to remove that namespace from the
    xml document and then processing it.

    Thanks for any ideas!
    Alexander Kleshchevnikov


  • Martin Honnen

    #2
    Re: XmlTransform validate on parse

    seigo wrote:
    Xml document contains the following namespace:
    >
    <Primetime_Scre ening
    xmlns="http://www.medicalhist ory.com/PrimetimeScreen ing" ..>
    You need to write your XPath expressions and XSLT match patterns the
    proper way to match/select elements in the default namespace:
    <http://www.faqts.com/knowledge_base/view.phtml/aid/34022/fid/616>

    --

    Martin Honnen --- MVP XML

    Comment

    • seigo

      #3
      Re: XmlTransform validate on parse

      Hi Martin,

      Thanks, I know the problem now. But how can I change my code? Or do I
      need to change xsl document? How, for instance, I can address this
      <xsl:value-of
      select="/Primetime_Scree ning/Report/Chief_Complaint/Narrative" />?

      Thanks,
      Alexander Kleshchevnikov


      Martin Honnen íàïèñàâ:
      seigo wrote:
      >
      Xml document contains the following namespace:

      <Primetime_Scre ening
      xmlns="http://www.medicalhist ory.com/PrimetimeScreen ing" ..>
      >
      You need to write your XPath expressions and XSLT match patterns the
      proper way to match/select elements in the default namespace:
      <http://www.faqts.com/knowledge_base/view.phtml/aid/34022/fid/616>

      --

      Martin Honnen --- MVP XML
      http://JavaScript.FAQTs.com/

      Comment

      • Martin Honnen

        #4
        Re: XmlTransform validate on parse

        seigo wrote:
        Thanks, I know the problem now. But how can I change my code? Or do I
        need to change xsl document? How, for instance, I can address this
        <xsl:value-of
        select="/Primetime_Scree ning/Report/Chief_Complaint/Narrative" />?
        Yes, you need to change the stylesheet, as described in
        ><http://www.faqts.com/knowledge_base/view.phtml/aid/34022/fid/616>
        you need to bind a prefix to that namespace URI and use that prefix in
        XPath expressions e.g.

        <xsl:styleshe et
        xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
        xmlns:ps="http://www.medicalhist ory.com/PrimetimeScreen ing"
        version="1.0">

        <xsl:template match="/">
        <xsl:value-of
        select="/ps:Primetime_Sc reening/ps:Report/ps:Chief_Compla int/ps:Narrative"
        />
        </xsl:template>


        At least that is what I guess you have to do, you have only shown the
        first line of your input XML.

        --

        Martin Honnen --- MVP XML

        Comment

        Working...