xupdate (2)

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

xupdate (2)

Oliver Charlet
sorry, i also here attach the TemplateHandlerImpl class. It now includes
two additional two else branches for Rename and Comment tags.

--
-----------------------
oliver charlet
software development

11-041 Olsztyn, Poland

[hidden email]
-----------------------


/**
 *  Copyright (C) 2004 Orbeon, Inc.
 *
 *  This program is free software; you can redistribute it and/or modify it under the terms of the
 *  GNU Lesser General Public License as published by the Free Software Foundation; either version
 *  2.1 of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *  See the GNU Lesser General Public License for more details.
 *
 *  The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
 */
package org.orbeon.oxf.transformer.xupdate;

import org.dom4j.*;
import org.jaxen.NamespaceContext;
import org.jaxen.SimpleNamespaceContext;
import org.orbeon.oxf.common.OXFException;
import org.orbeon.oxf.common.ValidationException;
import org.orbeon.oxf.transformer.xupdate.statement.*;
import org.orbeon.oxf.transformer.xupdate.statement.Attribute;
import org.orbeon.oxf.transformer.xupdate.statement.Comment;
import org.orbeon.oxf.transformer.xupdate.statement.Error;
import org.orbeon.oxf.transformer.xupdate.statement.Namespace;
import org.orbeon.oxf.transformer.xupdate.statement.Text;
import org.orbeon.oxf.xml.dom4j.Dom4jUtils;
import org.orbeon.oxf.xml.dom4j.LocationData;
import org.orbeon.oxf.xml.dom4j.LocationSAXContentHandler;
import org.orbeon.oxf.xml.dom4j.NonLazyUserDataElement;

import javax.xml.transform.sax.TemplatesHandler;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class TemplatesHandlerImpl extends LocationSAXContentHandler implements TemplatesHandler  {

    public javax.xml.transform.Templates getTemplates() {
        Document xupdateDocument = getDocument();
        return new TemplatesImpl(parseStatements(xupdateDocument.getRootElement().elements()));
    }

    public void setSystemId(String systemID) {
    }

    public String getSystemId() {
        return null;
    }

    private Statement[] parseStatements(List nodes) {
        List statements = new ArrayList();
        for (Iterator i = nodes.iterator(); i.hasNext();) {
            Node node = (Node) i.next();
            if (node.getNodeType() == Node.TEXT_NODE) {
                if (! "".equals(node.getText().trim()))
                    statements.add(new Text(node.getText().trim()));
            } else if (node.getNodeType() == Node.ELEMENT_NODE) {
                Element element = (Element) node;
                NamespaceContext namespaceContext = new SimpleNamespaceContext(Dom4jUtils.getNamespaceContext(element));
                if (XUpdateConstants.XUPDATE_NAMESPACE_URI.equals(element.getNamespaceURI())) {
                    if (element.getName().equals("remove")) {
                        statements.add(new Remove((LocationData) element.getData(), element.attributeValue("select"), namespaceContext));
                    } else if (element.getName().equals("update")) {
                        statements.add(new Update((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
                                parseStatements(element.content())));
                    } else if (element.getName().equals("append")) {
                        statements.add(new Append((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
                                element.attributeValue("child"),
                                parseStatements(element.content())));
                    } else if (element.getName().equals("insert-before")) {
                        statements.add(new InsertBefore((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
                                parseStatements(element.content())));
                    } else if (element.getName().equals("insert-after")) {
                        statements.add(new InsertAfter((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
                                parseStatements(element.content())));
                    } else if (element.getName().equals("for-each")) {
                        statements.add(new ForEach((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
                                parseStatements(element.content())));
                    } else if (element.getName().equals("while")) {
                        statements.add(new While((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
                                parseStatements(element.content())));
                    } else if (element.getName().equals("value-of")) {
                        statements.add(new ValueOf((LocationData) element.getData(), element.attributeValue("select"), namespaceContext));
                    } else if (element.getName().equals("copy-of")) {
                        statements.add(new CopyOf((LocationData) element.getData(), element.attributeValue("select"), namespaceContext));
                    } else if (element.getName().equals("attribute")) {
                        statements.add(new Attribute((LocationData) element.getData(), parseQName(element),
                                parseStatements(element.content())));
                    } else if (element.getName().equals("namespace")) {
                        statements.add(new Namespace((LocationData) element.getData(), element.attributeValue("name"),
                                element.attributeValue("select"), namespaceContext, parseStatements(element.content())));
                    } else if (element.getName().equals("element")) {
                        statements.add(new DynamicElement((LocationData) element.getData(), parseQName(element),
                                parseStatements(element.content())));
                    } else if (element.getName().equals("if")) {
                        statements.add(new If((LocationData) element.getData(), element.attributeValue("test"), namespaceContext,
                                parseStatements(element.content())));
                    } else if (element.getName().equals("choose")) {
                        List whenTests = new ArrayList();
                        List whenNamespaceContext = new ArrayList();
                        List whenStatements = new ArrayList();
                        for (Iterator j = element.elements("when").iterator(); j.hasNext();) {
                            Element whenElement = (Element) j.next();
                            whenTests.add(whenElement.attributeValue("test"));
                            whenNamespaceContext.add(new SimpleNamespaceContext(Dom4jUtils.getNamespaceContext(whenElement)));
                            whenStatements.add(parseStatements(whenElement.content()));
                        }
                        Element otherwiseElement = element.element("otherwise");
                        statements.add(new Choose((LocationData) element.getData(), (String[]) whenTests.toArray(new String[whenTests.size()]),
                                (NamespaceContext[]) whenNamespaceContext.toArray(new NamespaceContext[whenNamespaceContext.size()]),
                                (Statement[][]) whenStatements.toArray(new Statement[whenStatements.size()][]),
                                otherwiseElement == null ? null : parseStatements(otherwiseElement.content())));
                    } else if (element.getName().equals("variable")) {
                        statements.add(new Variable((LocationData) element.getData(), parseQName(element), element.attributeValue("select"),
                                namespaceContext, parseStatements(element.content())));
                    } else if (element.getName().equals("assign")) {
                        statements.add(new Assign((LocationData) element.getData(), parseQName(element), element.attributeValue("select"),
                                namespaceContext, parseStatements(element.content())));
                    } else if (element.getName().equals("function")) {
                        statements.add(new Function((LocationData) element.getData(), parseQName(element), parseStatements(element.content())));
                    } else if (element.getName().equals("param")) {
                        statements.add(new Param((LocationData) element.getData(), parseQName(element), element.attributeValue("select"),
                                namespaceContext, parseStatements(element.content())));
                    } else if (element.getName().equals("message")) {
                        statements.add(new Message((LocationData) element.getData(), parseStatements(element.content())));
                    } else if (element.getName().equals("error")) {
                        statements.add(new Error((LocationData) element.getData(), parseStatements(element.content())));
                    } else if (element.getName().equals("rename")) {
                        statements.add(new Rename((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
                                parseStatements(element.content())));
                    } else if (element.getName().equals("comment")) {
                        statements.add(new Comment((LocationData) element.getData(), parseStatements(element.content())));
                    } else {
                        throw new ValidationException("Unsupported XUpdate element '"
                                + element.getQualifiedName() + "'", (LocationData) element.getData());
                    }
                } else {
                    Element staticElement = new NonLazyUserDataElement(element.getQName());
                    List childNodes = new ArrayList();
                    for (Iterator j = element.attributes().iterator(); j.hasNext();)
                        staticElement.add((org.dom4j.Attribute) ((org.dom4j.Attribute) j.next()).clone());
                    for (Iterator j = element.content().iterator(); j.hasNext();) {
                        Node child = (Node) j.next();
                        if (child instanceof org.dom4j.Namespace) {
                            staticElement.add((Node) child.clone());
                        } else {
                            childNodes.add(child);
                        }
                    }
                    statements.add(new StaticElement((LocationData) element.getData(),
                            staticElement, parseStatements(childNodes)));
                }
            } else if (node.getNodeType() == Node.NAMESPACE_NODE) {
                // Ignore namespace declarations
            } else {
                throw new OXFException("Unsupported node: " + node.getNodeTypeName());
            }
        }
        return (Statement[]) statements.toArray(new Statement[statements.size()]);
    }

    /**
     * Parse a name / namespace attributes of <xu:element> and
     * <xu:attribute>
     */
    private QName parseQName(Element element) {
        String name = element.attributeValue("name");
        String namespace = element.attributeValue("namespace");
        int columnPosition = name.indexOf(':');

        // Check syntax of qname
        if (columnPosition == 0 || columnPosition == name.length() - 1)
            throw new ValidationException("Invalid qname '" + name + "'", (LocationData) element.getData());

        if (columnPosition == -1 && namespace == null) {
            // Simple name
            return new QName(name);
        } else  if (columnPosition != -1 && namespace == null) {
            // Qualified name using namespace declaration in context
            String prefix = name.substring(0, columnPosition);
            String namespaceFromContext = (String) Dom4jUtils.getNamespaceContext(element).get(prefix);
            if (namespaceFromContext == null)
                throw new ValidationException("No namespace declared for prefix '" + prefix + "'",
                        (LocationData) element.getData());
            return new QName(name.substring(columnPosition + 1), new org.dom4j.Namespace(prefix, namespaceFromContext));
        } else if (columnPosition == -1 && namespace != null) {
            // Non-qualified name with namespace declaration
            return new QName(name, new org.dom4j.Namespace("", namespace));
        } else if (columnPosition != -1 && namespace != null) {
            // Qualified name using namespace specified
            return new QName(name.substring(columnPosition + 1),
                    new org.dom4j.Namespace(name.substring(0, columnPosition), namespace));
        } else {
            // This can't happen
            throw new OXFException("Invalid state");
        }
    }
}


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: xupdate (2)

Alessandro  Vernet
Administrator
Hi Olivier,

Let us know when you are done implementing both statements. Also, you
might want to write some unit tests for those new statements. You can
put those in tests-xupdate.xml, which already contains a number of
unit tests for XUpdate. Btw, when you send files in the list, you
might to attach them instead of doing a copy-paste in the body of the
message to avoid losing the formatting.

Alex

On 11/29/05, Oliver Charlet <[hidden email]> wrote:

> sorry, i also here attach the TemplateHandlerImpl class. It now includes
> two additional two else branches for Rename and Comment tags.
>
> --
> -----------------------
> oliver charlet
> software development
>
> 11-041 Olsztyn, Poland
>
> [hidden email]
> -----------------------
>
>
>
> /**
>  *  Copyright (C) 2004 Orbeon, Inc.
>  *
>  *  This program is free software; you can redistribute it and/or modify it under the terms of the
>  *  GNU Lesser General Public License as published by the Free Software Foundation; either version
>  *  2.1 of the License, or (at your option) any later version.
>  *
>  *  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
>  *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>  *  See the GNU Lesser General Public License for more details.
>  *
>  *  The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
>  */
> package org.orbeon.oxf.transformer.xupdate;
>
> import org.dom4j.*;
> import org.jaxen.NamespaceContext;
> import org.jaxen.SimpleNamespaceContext;
> import org.orbeon.oxf.common.OXFException;
> import org.orbeon.oxf.common.ValidationException;
> import org.orbeon.oxf.transformer.xupdate.statement.*;
> import org.orbeon.oxf.transformer.xupdate.statement.Attribute;
> import org.orbeon.oxf.transformer.xupdate.statement.Comment;
> import org.orbeon.oxf.transformer.xupdate.statement.Error;
> import org.orbeon.oxf.transformer.xupdate.statement.Namespace;
> import org.orbeon.oxf.transformer.xupdate.statement.Text;
> import org.orbeon.oxf.xml.dom4j.Dom4jUtils;
> import org.orbeon.oxf.xml.dom4j.LocationData;
> import org.orbeon.oxf.xml.dom4j.LocationSAXContentHandler;
> import org.orbeon.oxf.xml.dom4j.NonLazyUserDataElement;
>
> import javax.xml.transform.sax.TemplatesHandler;
> import java.util.ArrayList;
> import java.util.Iterator;
> import java.util.List;
>
> public class TemplatesHandlerImpl extends LocationSAXContentHandler implements TemplatesHandler  {
>
>     public javax.xml.transform.Templates getTemplates() {
>         Document xupdateDocument = getDocument();
>         return new TemplatesImpl(parseStatements(xupdateDocument.getRootElement().elements()));
>     }
>
>     public void setSystemId(String systemID) {
>     }
>
>     public String getSystemId() {
>         return null;
>     }
>
>     private Statement[] parseStatements(List nodes) {
>         List statements = new ArrayList();
>         for (Iterator i = nodes.iterator(); i.hasNext();) {
>             Node node = (Node) i.next();
>             if (node.getNodeType() == Node.TEXT_NODE) {
>                 if (! "".equals(node.getText().trim()))
>                     statements.add(new Text(node.getText().trim()));
>             } else if (node.getNodeType() == Node.ELEMENT_NODE) {
>                 Element element = (Element) node;
>                 NamespaceContext namespaceContext = new SimpleNamespaceContext(Dom4jUtils.getNamespaceContext(element));
>                 if (XUpdateConstants.XUPDATE_NAMESPACE_URI.equals(element.getNamespaceURI())) {
>                     if (element.getName().equals("remove")) {
>                         statements.add(new Remove((LocationData) element.getData(), element.attributeValue("select"), namespaceContext));
>                     } else if (element.getName().equals("update")) {
>                         statements.add(new Update((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
>                                 parseStatements(element.content())));
>                     } else if (element.getName().equals("append")) {
>                         statements.add(new Append((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
>                                 element.attributeValue("child"),
>                                 parseStatements(element.content())));
>                     } else if (element.getName().equals("insert-before")) {
>                         statements.add(new InsertBefore((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
>                                 parseStatements(element.content())));
>                     } else if (element.getName().equals("insert-after")) {
>                         statements.add(new InsertAfter((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
>                                 parseStatements(element.content())));
>                     } else if (element.getName().equals("for-each")) {
>                         statements.add(new ForEach((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
>                                 parseStatements(element.content())));
>                     } else if (element.getName().equals("while")) {
>                         statements.add(new While((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
>                                 parseStatements(element.content())));
>                     } else if (element.getName().equals("value-of")) {
>                         statements.add(new ValueOf((LocationData) element.getData(), element.attributeValue("select"), namespaceContext));
>                     } else if (element.getName().equals("copy-of")) {
>                         statements.add(new CopyOf((LocationData) element.getData(), element.attributeValue("select"), namespaceContext));
>                     } else if (element.getName().equals("attribute")) {
>                         statements.add(new Attribute((LocationData) element.getData(), parseQName(element),
>                                 parseStatements(element.content())));
>                     } else if (element.getName().equals("namespace")) {
>                         statements.add(new Namespace((LocationData) element.getData(), element.attributeValue("name"),
>                                 element.attributeValue("select"), namespaceContext, parseStatements(element.content())));
>                     } else if (element.getName().equals("element")) {
>                         statements.add(new DynamicElement((LocationData) element.getData(), parseQName(element),
>                                 parseStatements(element.content())));
>                     } else if (element.getName().equals("if")) {
>                         statements.add(new If((LocationData) element.getData(), element.attributeValue("test"), namespaceContext,
>                                 parseStatements(element.content())));
>                     } else if (element.getName().equals("choose")) {
>                         List whenTests = new ArrayList();
>                         List whenNamespaceContext = new ArrayList();
>                         List whenStatements = new ArrayList();
>                         for (Iterator j = element.elements("when").iterator(); j.hasNext();) {
>                             Element whenElement = (Element) j.next();
>                             whenTests.add(whenElement.attributeValue("test"));
>                             whenNamespaceContext.add(new SimpleNamespaceContext(Dom4jUtils.getNamespaceContext(whenElement)));
>                             whenStatements.add(parseStatements(whenElement.content()));
>                         }
>                         Element otherwiseElement = element.element("otherwise");
>                         statements.add(new Choose((LocationData) element.getData(), (String[]) whenTests.toArray(new String[whenTests.size()]),
>                                 (NamespaceContext[]) whenNamespaceContext.toArray(new NamespaceContext[whenNamespaceContext.size()]),
>                                 (Statement[][]) whenStatements.toArray(new Statement[whenStatements.size()][]),
>                                 otherwiseElement == null ? null : parseStatements(otherwiseElement.content())));
>                     } else if (element.getName().equals("variable")) {
>                         statements.add(new Variable((LocationData) element.getData(), parseQName(element), element.attributeValue("select"),
>                                 namespaceContext, parseStatements(element.content())));
>                     } else if (element.getName().equals("assign")) {
>                         statements.add(new Assign((LocationData) element.getData(), parseQName(element), element.attributeValue("select"),
>                                 namespaceContext, parseStatements(element.content())));
>                     } else if (element.getName().equals("function")) {
>                         statements.add(new Function((LocationData) element.getData(), parseQName(element), parseStatements(element.content())));
>                     } else if (element.getName().equals("param")) {
>                         statements.add(new Param((LocationData) element.getData(), parseQName(element), element.attributeValue("select"),
>                                 namespaceContext, parseStatements(element.content())));
>                     } else if (element.getName().equals("message")) {
>                         statements.add(new Message((LocationData) element.getData(), parseStatements(element.content())));
>                     } else if (element.getName().equals("error")) {
>                         statements.add(new Error((LocationData) element.getData(), parseStatements(element.content())));
>                     } else if (element.getName().equals("rename")) {
>                         statements.add(new Rename((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
>                                 parseStatements(element.content())));
>                     } else if (element.getName().equals("comment")) {
>                         statements.add(new Comment((LocationData) element.getData(), parseStatements(element.content())));
>                     } else {
>                         throw new ValidationException("Unsupported XUpdate element '"
>                                 + element.getQualifiedName() + "'", (LocationData) element.getData());
>                     }
>                 } else {
>                     Element staticElement = new NonLazyUserDataElement(element.getQName());
>                     List childNodes = new ArrayList();
>                     for (Iterator j = element.attributes().iterator(); j.hasNext();)
>                         staticElement.add((org.dom4j.Attribute) ((org.dom4j.Attribute) j.next()).clone());
>                     for (Iterator j = element.content().iterator(); j.hasNext();) {
>                         Node child = (Node) j.next();
>                         if (child instanceof org.dom4j.Namespace) {
>                             staticElement.add((Node) child.clone());
>                         } else {
>                             childNodes.add(child);
>                         }
>                     }
>                     statements.add(new StaticElement((LocationData) element.getData(),
>                             staticElement, parseStatements(childNodes)));
>                 }
>             } else if (node.getNodeType() == Node.NAMESPACE_NODE) {
>                 // Ignore namespace declarations
>             } else {
>                 throw new OXFException("Unsupported node: " + node.getNodeTypeName());
>             }
>         }
>         return (Statement[]) statements.toArray(new Statement[statements.size()]);
>     }
>
>     /**
>      * Parse a name / namespace attributes of &lt;xu:element> and
>      * &lt;xu:attribute>
>      */
>     private QName parseQName(Element element) {
>         String name = element.attributeValue("name");
>         String namespace = element.attributeValue("namespace");
>         int columnPosition = name.indexOf(':');
>
>         // Check syntax of qname
>         if (columnPosition == 0 || columnPosition == name.length() - 1)
>             throw new ValidationException("Invalid qname '" + name + "'", (LocationData) element.getData());
>
>         if (columnPosition == -1 && namespace == null) {
>             // Simple name
>             return new QName(name);
>         } else  if (columnPosition != -1 && namespace == null) {
>             // Qualified name using namespace declaration in context
>             String prefix = name.substring(0, columnPosition);
>             String namespaceFromContext = (String) Dom4jUtils.getNamespaceContext(element).get(prefix);
>             if (namespaceFromContext == null)
>                 throw new ValidationException("No namespace declared for prefix '" + prefix + "'",
>                         (LocationData) element.getData());
>             return new QName(name.substring(columnPosition + 1), new org.dom4j.Namespace(prefix, namespaceFromContext));
>         } else if (columnPosition == -1 && namespace != null) {
>             // Non-qualified name with namespace declaration
>             return new QName(name, new org.dom4j.Namespace("", namespace));
>         } else if (columnPosition != -1 && namespace != null) {
>             // Qualified name using namespace specified
>             return new QName(name.substring(columnPosition + 1),
>                     new org.dom4j.Namespace(name.substring(0, columnPosition), namespace));
>         } else {
>             // This can't happen
>             throw new OXFException("Invalid state");
>         }
>     }
> }
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>

--
Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: xupdate (2)

Oliver Charlet
Hi Alessandro,

I didn't know about sax not supporting comments. So I think we should leave that, since it is not such a highly wanted feature.
I actually attached the source file, but thunderbird obviously decided to inline the content - very strange. And I'll do a test.


Alessandro Vernet schrieb:
Hi Olivier,

Let us know when you are done implementing both statements. Also, you
might want to write some unit tests for those new statements. You can
put those in tests-xupdate.xml, which already contains a number of
unit tests for XUpdate. Btw, when you send files in the list, you
might to attach them instead of doing a copy-paste in the body of the
message to avoid losing the formatting.

Alex

On 11/29/05, Oliver Charlet [hidden email] wrote:
  
sorry, i also here attach the TemplateHandlerImpl class. It now includes
two additional two else branches for Rename and Comment tags.

--
-----------------------
oliver charlet
software development

11-041 Olsztyn, Poland

[hidden email]
-----------------------



/**
 *  Copyright (C) 2004 Orbeon, Inc.
 *
 *  This program is free software; you can redistribute it and/or modify it under the terms of the
 *  GNU Lesser General Public License as published by the Free Software Foundation; either version
 *  2.1 of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *  See the GNU Lesser General Public License for more details.
 *
 *  The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
 */
package org.orbeon.oxf.transformer.xupdate;

import org.dom4j.*;
import org.jaxen.NamespaceContext;
import org.jaxen.SimpleNamespaceContext;
import org.orbeon.oxf.common.OXFException;
import org.orbeon.oxf.common.ValidationException;
import org.orbeon.oxf.transformer.xupdate.statement.*;
import org.orbeon.oxf.transformer.xupdate.statement.Attribute;
import org.orbeon.oxf.transformer.xupdate.statement.Comment;
import org.orbeon.oxf.transformer.xupdate.statement.Error;
import org.orbeon.oxf.transformer.xupdate.statement.Namespace;
import org.orbeon.oxf.transformer.xupdate.statement.Text;
import org.orbeon.oxf.xml.dom4j.Dom4jUtils;
import org.orbeon.oxf.xml.dom4j.LocationData;
import org.orbeon.oxf.xml.dom4j.LocationSAXContentHandler;
import org.orbeon.oxf.xml.dom4j.NonLazyUserDataElement;

import javax.xml.transform.sax.TemplatesHandler;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class TemplatesHandlerImpl extends LocationSAXContentHandler implements TemplatesHandler  {

    public javax.xml.transform.Templates getTemplates() {
        Document xupdateDocument = getDocument();
        return new TemplatesImpl(parseStatements(xupdateDocument.getRootElement().elements()));
    }

    public void setSystemId(String systemID) {
    }

    public String getSystemId() {
        return null;
    }

    private Statement[] parseStatements(List nodes) {
        List statements = new ArrayList();
        for (Iterator i = nodes.iterator(); i.hasNext();) {
            Node node = (Node) i.next();
            if (node.getNodeType() == Node.TEXT_NODE) {
                if (! "".equals(node.getText().trim()))
                    statements.add(new Text(node.getText().trim()));
            } else if (node.getNodeType() == Node.ELEMENT_NODE) {
                Element element = (Element) node;
                NamespaceContext namespaceContext = new SimpleNamespaceContext(Dom4jUtils.getNamespaceContext(element));
                if (XUpdateConstants.XUPDATE_NAMESPACE_URI.equals(element.getNamespaceURI())) {
                    if (element.getName().equals("remove")) {
                        statements.add(new Remove((LocationData) element.getData(), element.attributeValue("select"), namespaceContext));
                    } else if (element.getName().equals("update")) {
                        statements.add(new Update((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
                                parseStatements(element.content())));
                    } else if (element.getName().equals("append")) {
                        statements.add(new Append((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
                                element.attributeValue("child"),
                                parseStatements(element.content())));
                    } else if (element.getName().equals("insert-before")) {
                        statements.add(new InsertBefore((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
                                parseStatements(element.content())));
                    } else if (element.getName().equals("insert-after")) {
                        statements.add(new InsertAfter((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
                                parseStatements(element.content())));
                    } else if (element.getName().equals("for-each")) {
                        statements.add(new ForEach((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
                                parseStatements(element.content())));
                    } else if (element.getName().equals("while")) {
                        statements.add(new While((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
                                parseStatements(element.content())));
                    } else if (element.getName().equals("value-of")) {
                        statements.add(new ValueOf((LocationData) element.getData(), element.attributeValue("select"), namespaceContext));
                    } else if (element.getName().equals("copy-of")) {
                        statements.add(new CopyOf((LocationData) element.getData(), element.attributeValue("select"), namespaceContext));
                    } else if (element.getName().equals("attribute")) {
                        statements.add(new Attribute((LocationData) element.getData(), parseQName(element),
                                parseStatements(element.content())));
                    } else if (element.getName().equals("namespace")) {
                        statements.add(new Namespace((LocationData) element.getData(), element.attributeValue("name"),
                                element.attributeValue("select"), namespaceContext, parseStatements(element.content())));
                    } else if (element.getName().equals("element")) {
                        statements.add(new DynamicElement((LocationData) element.getData(), parseQName(element),
                                parseStatements(element.content())));
                    } else if (element.getName().equals("if")) {
                        statements.add(new If((LocationData) element.getData(), element.attributeValue("test"), namespaceContext,
                                parseStatements(element.content())));
                    } else if (element.getName().equals("choose")) {
                        List whenTests = new ArrayList();
                        List whenNamespaceContext = new ArrayList();
                        List whenStatements = new ArrayList();
                        for (Iterator j = element.elements("when").iterator(); j.hasNext();) {
                            Element whenElement = (Element) j.next();
                            whenTests.add(whenElement.attributeValue("test"));
                            whenNamespaceContext.add(new SimpleNamespaceContext(Dom4jUtils.getNamespaceContext(whenElement)));
                            whenStatements.add(parseStatements(whenElement.content()));
                        }
                        Element otherwiseElement = element.element("otherwise");
                        statements.add(new Choose((LocationData) element.getData(), (String[]) whenTests.toArray(new String[whenTests.size()]),
                                (NamespaceContext[]) whenNamespaceContext.toArray(new NamespaceContext[whenNamespaceContext.size()]),
                                (Statement[][]) whenStatements.toArray(new Statement[whenStatements.size()][]),
                                otherwiseElement == null ? null : parseStatements(otherwiseElement.content())));
                    } else if (element.getName().equals("variable")) {
                        statements.add(new Variable((LocationData) element.getData(), parseQName(element), element.attributeValue("select"),
                                namespaceContext, parseStatements(element.content())));
                    } else if (element.getName().equals("assign")) {
                        statements.add(new Assign((LocationData) element.getData(), parseQName(element), element.attributeValue("select"),
                                namespaceContext, parseStatements(element.content())));
                    } else if (element.getName().equals("function")) {
                        statements.add(new Function((LocationData) element.getData(), parseQName(element), parseStatements(element.content())));
                    } else if (element.getName().equals("param")) {
                        statements.add(new Param((LocationData) element.getData(), parseQName(element), element.attributeValue("select"),
                                namespaceContext, parseStatements(element.content())));
                    } else if (element.getName().equals("message")) {
                        statements.add(new Message((LocationData) element.getData(), parseStatements(element.content())));
                    } else if (element.getName().equals("error")) {
                        statements.add(new Error((LocationData) element.getData(), parseStatements(element.content())));
                    } else if (element.getName().equals("rename")) {
                        statements.add(new Rename((LocationData) element.getData(), element.attributeValue("select"), namespaceContext,
                                parseStatements(element.content())));
                    } else if (element.getName().equals("comment")) {
                        statements.add(new Comment((LocationData) element.getData(), parseStatements(element.content())));
                    } else {
                        throw new ValidationException("Unsupported XUpdate element '"
                                + element.getQualifiedName() + "'", (LocationData) element.getData());
                    }
                } else {
                    Element staticElement = new NonLazyUserDataElement(element.getQName());
                    List childNodes = new ArrayList();
                    for (Iterator j = element.attributes().iterator(); j.hasNext();)
                        staticElement.add((org.dom4j.Attribute) ((org.dom4j.Attribute) j.next()).clone());
                    for (Iterator j = element.content().iterator(); j.hasNext();) {
                        Node child = (Node) j.next();
                        if (child instanceof org.dom4j.Namespace) {
                            staticElement.add((Node) child.clone());
                        } else {
                            childNodes.add(child);
                        }
                    }
                    statements.add(new StaticElement((LocationData) element.getData(),
                            staticElement, parseStatements(childNodes)));
                }
            } else if (node.getNodeType() == Node.NAMESPACE_NODE) {
                // Ignore namespace declarations
            } else {
                throw new OXFException("Unsupported node: " + node.getNodeTypeName());
            }
        }
        return (Statement[]) statements.toArray(new Statement[statements.size()]);
    }

    /**
     * Parse a name / namespace attributes of &lt;xu:element> and
     * &lt;xu:attribute>
     */
    private QName parseQName(Element element) {
        String name = element.attributeValue("name");
        String namespace = element.attributeValue("namespace");
        int columnPosition = name.indexOf(':');

        // Check syntax of qname
        if (columnPosition == 0 || columnPosition == name.length() - 1)
            throw new ValidationException("Invalid qname '" + name + "'", (LocationData) element.getData());

        if (columnPosition == -1 && namespace == null) {
            // Simple name
            return new QName(name);
        } else  if (columnPosition != -1 && namespace == null) {
            // Qualified name using namespace declaration in context
            String prefix = name.substring(0, columnPosition);
            String namespaceFromContext = (String) Dom4jUtils.getNamespaceContext(element).get(prefix);
            if (namespaceFromContext == null)
                throw new ValidationException("No namespace declared for prefix '" + prefix + "'",
                        (LocationData) element.getData());
            return new QName(name.substring(columnPosition + 1), new org.dom4j.Namespace(prefix, namespaceFromContext));
        } else if (columnPosition == -1 && namespace != null) {
            // Non-qualified name with namespace declaration
            return new QName(name, new org.dom4j.Namespace("", namespace));
        } else if (columnPosition != -1 && namespace != null) {
            // Qualified name using namespace specified
            return new QName(name.substring(columnPosition + 1),
                    new org.dom4j.Namespace(name.substring(0, columnPosition), namespace));
        } else {
            // This can't happen
            throw new OXFException("Invalid state");
        }
    }
}



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



    


--
Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/

  

-- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: [hidden email] For general help: [hidden email] ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

-- 
-----------------------
oliver charlet
software development

11-041 Olsztyn, Poland

[hidden email]
-----------------------


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: xupdate (2)

Alessandro  Vernet
Administrator
Hi Oliver,

Actually after double checking this, you were right: the file was
correctly attached, but it is my client that decided to display it as
if it was inline. So attaching files the way you did works fine.

Alex

On 12/1/05, Oliver Charlet <[hidden email]> wrote:

>  Hi Alessandro,
>
>  I didn't know about sax not supporting comments. So I think we should leave
> that, since it is not such a highly wanted feature.
>  I actually attached the source file, but thunderbird obviously decided to
> inline the content - very strange. And I'll do a test.
>
>
>  Alessandro Vernet schrieb:
>  Hi Olivier,
>
> Let us know when you are done implementing both statements. Also, you
> might want to write some unit tests for those new statements. You can
> put those in tests-xupdate.xml, which already contains a number of
> unit tests for XUpdate. Btw, when you send files in the list, you
> might to attach them instead of doing a copy-paste in the body of the
> message to avoid losing the formatting.
>
> Alex
>
> On 11/29/05, Oliver Charlet <[hidden email]> wrote:
>
>
>  sorry, i also here attach the TemplateHandlerImpl class. It now includes
> two additional two else branches for Rename and Comment tags.
>
> --
> -----------------------
> oliver charlet
> software development
>
> 11-041 Olsztyn, Poland
>
> [hidden email]
> -----------------------
>
>
>
> /**
>  * Copyright (C) 2004 Orbeon, Inc.
>  *
>  * This program is free software; you can redistribute it and/or modify it
> under the terms of the
>  * GNU Lesser General Public License as published by the Free Software
> Foundation; either version
>  * 2.1 of the License, or (at your option) any later version.
>  *
>  * This program is distributed in the hope that it will be useful, but
> WITHOUT ANY WARRANTY;
>  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
> PARTICULAR PURPOSE.
>  * See the GNU Lesser General Public License for more details.
>  *
>  * The full text of the license is available at
> http://www.gnu.org/copyleft/lesser.html
>  */
> package org.orbeon.oxf.transformer.xupdate;
>
> import org.dom4j.*;
> import org.jaxen.NamespaceContext;
> import org.jaxen.SimpleNamespaceContext;
> import org.orbeon.oxf.common.OXFException;
> import org.orbeon.oxf.common.ValidationException;
> import org.orbeon.oxf.transformer.xupdate.statement.*;
> import
> org.orbeon.oxf.transformer.xupdate.statement.Attribute;
> import
> org.orbeon.oxf.transformer.xupdate.statement.Comment;
> import org.orbeon.oxf.transformer.xupdate.statement.Error;
> import
> org.orbeon.oxf.transformer.xupdate.statement.Namespace;
> import org.orbeon.oxf.transformer.xupdate.statement.Text;
> import org.orbeon.oxf.xml.dom4j.Dom4jUtils;
> import org.orbeon.oxf.xml.dom4j.LocationData;
> import org.orbeon.oxf.xml.dom4j.LocationSAXContentHandler;
> import org.orbeon.oxf.xml.dom4j.NonLazyUserDataElement;
>
> import javax.xml.transform.sax.TemplatesHandler;
> import java.util.ArrayList;
> import java.util.Iterator;
> import java.util.List;
>
> public class TemplatesHandlerImpl extends LocationSAXContentHandler
> implements TemplatesHandler {
>
>  public javax.xml.transform.Templates getTemplates() {
>  Document xupdateDocument = getDocument();
>  return new
> TemplatesImpl(parseStatements(xupdateDocument.getRootElement().elements()));
>  }
>
>  public void setSystemId(String systemID) {
>  }
>
>  public String getSystemId() {
>  return null;
>  }
>
>  private Statement[] parseStatements(List nodes) {
>  List statements = new ArrayList();
>  for (Iterator i = nodes.iterator(); i.hasNext();) {
>  Node node = (Node) i.next();
>  if (node.getNodeType() == Node.TEXT_NODE) {
>  if (! "".equals(node.getText().trim()))
>  statements.add(new Text(node.getText().trim()));
>  } else if (node.getNodeType() == Node.ELEMENT_NODE) {
>  Element element = (Element) node;
>  NamespaceContext namespaceContext = new
> SimpleNamespaceContext(Dom4jUtils.getNamespaceContext(element));
>  if
> (XUpdateConstants.XUPDATE_NAMESPACE_URI.equals(element.getNamespaceURI()))
> {
>  if (element.getName().equals("remove")) {
>  statements.add(new Remove((LocationData) element.getData(),
> element.attributeValue("select"), namespaceContext));
>  } else if (element.getName().equals("update")) {
>  statements.add(new Update((LocationData) element.getData(),
> element.attributeValue("select"), namespaceContext,
>  parseStatements(element.content())));
>  } else if (element.getName().equals("append")) {
>  statements.add(new Append((LocationData) element.getData(),
> element.attributeValue("select"), namespaceContext,
>  element.attributeValue("child"),
>  parseStatements(element.content())));
>  } else if (element.getName().equals("insert-before")) {
>  statements.add(new InsertBefore((LocationData) element.getData(),
> element.attributeValue("select"), namespaceContext,
>  parseStatements(element.content())));
>  } else if (element.getName().equals("insert-after")) {
>  statements.add(new InsertAfter((LocationData) element.getData(),
> element.attributeValue("select"), namespaceContext,
>  parseStatements(element.content())));
>  } else if (element.getName().equals("for-each")) {
>  statements.add(new ForEach((LocationData) element.getData(),
> element.attributeValue("select"), namespaceContext,
>  parseStatements(element.content())));
>  } else if (element.getName().equals("while")) {
>  statements.add(new While((LocationData) element.getData(),
> element.attributeValue("select"), namespaceContext,
>  parseStatements(element.content())));
>  } else if (element.getName().equals("value-of")) {
>  statements.add(new ValueOf((LocationData) element.getData(),
> element.attributeValue("select"), namespaceContext));
>  } else if (element.getName().equals("copy-of")) {
>  statements.add(new CopyOf((LocationData) element.getData(),
> element.attributeValue("select"), namespaceContext));
>  } else if (element.getName().equals("attribute")) {
>  statements.add(new Attribute((LocationData) element.getData(),
> parseQName(element),
>  parseStatements(element.content())));
>  } else if (element.getName().equals("namespace")) {
>  statements.add(new Namespace((LocationData) element.getData(),
> element.attributeValue("name"),
>  element.attributeValue("select"), namespaceContext,
> parseStatements(element.content())));
>  } else if (element.getName().equals("element")) {
>  statements.add(new DynamicElement((LocationData) element.getData(),
> parseQName(element),
>  parseStatements(element.content())));
>  } else if (element.getName().equals("if")) {
>  statements.add(new If((LocationData) element.getData(),
> element.attributeValue("test"), namespaceContext,
>  parseStatements(element.content())));
>  } else if (element.getName().equals("choose")) {
>  List whenTests = new ArrayList();
>  List whenNamespaceContext = new ArrayList();
>  List whenStatements = new ArrayList();
>  for (Iterator j = element.elements("when").iterator(); j.hasNext();) {
>  Element whenElement = (Element) j.next();
>  whenTests.add(whenElement.attributeValue("test"));
>  whenNamespaceContext.add(new
> SimpleNamespaceContext(Dom4jUtils.getNamespaceContext(whenElement)));
>  whenStatements.add(parseStatements(whenElement.content()));
>  }
>  Element otherwiseElement = element.element("otherwise");
>  statements.add(new Choose((LocationData) element.getData(), (String[])
> whenTests.toArray(new String[whenTests.size()]),
>  (NamespaceContext[]) whenNamespaceContext.toArray(new
> NamespaceContext[whenNamespaceContext.size()]),
>  (Statement[][]) whenStatements.toArray(new
> Statement[whenStatements.size()][]),
>  otherwiseElement == null ? null :
> parseStatements(otherwiseElement.content())));
>  } else if (element.getName().equals("variable")) {
>  statements.add(new Variable((LocationData) element.getData(),
> parseQName(element), element.attributeValue("select"),
>  namespaceContext, parseStatements(element.content())));
>  } else if (element.getName().equals("assign")) {
>  statements.add(new Assign((LocationData) element.getData(),
> parseQName(element), element.attributeValue("select"),
>  namespaceContext, parseStatements(element.content())));
>  } else if (element.getName().equals("function")) {
>  statements.add(new Function((LocationData) element.getData(),
> parseQName(element), parseStatements(element.content())));
>  } else if (element.getName().equals("param")) {
>  statements.add(new Param((LocationData) element.getData(),
> parseQName(element), element.attributeValue("select"),
>  namespaceContext, parseStatements(element.content())));
>  } else if (element.getName().equals("message")) {
>  statements.add(new Message((LocationData) element.getData(),
> parseStatements(element.content())));
>  } else if (element.getName().equals("error")) {
>  statements.add(new Error((LocationData) element.getData(),
> parseStatements(element.content())));
>  } else if (element.getName().equals("rename")) {
>  statements.add(new Rename((LocationData) element.getData(),
> element.attributeValue("select"), namespaceContext,
>  parseStatements(element.content())));
>  } else if (element.getName().equals("comment")) {
>  statements.add(new Comment((LocationData) element.getData(),
> parseStatements(element.content())));
>  } else {
>  throw new ValidationException("Unsupported XUpdate element
> '"
>  + element.getQualifiedName() + "'", (LocationData) element.getData());
>  }
>  } else {
>  Element staticElement = new NonLazyUserDataElement(element.getQName());
>  List childNodes = new ArrayList();
>  for (Iterator j = element.attributes().iterator(); j.hasNext();)
>  staticElement.add((org.dom4j.Attribute) ((org.dom4j.Attribute)
> j.next()).clone());
>  for (Iterator j = element.content().iterator(); j.hasNext();) {
>  Node child = (Node) j.next();
>  if (child instanceof org.dom4j.Namespace) {
>  staticElement.add((Node) child.clone());
>  } else {
>  childNodes.add(child);
>  }
>  }
>  statements.add(new StaticElement((LocationData) element.getData(),
>  staticElement, parseStatements(childNodes)));
>  }
>  } else if (node.getNodeType() == Node.NAMESPACE_NODE) {
>  // Ignore namespace declarations
>  } else {
>  throw new OXFException("Unsupported node: " + node.getNodeTypeName());
>  }
>  }
>  return (Statement[]) statements.toArray(new Statement[statements.size()]);
>  }
>
>  /**
>  * Parse a name / namespace attributes of &lt;xu:element> and
>  * &lt;xu:attribute>
>  */
>  private QName parseQName(Element element) {
>  String name = element.attributeValue("name");
>  String namespace = element.attributeValue("namespace");
>  int columnPosition = name.indexOf(':');
>
>  // Check syntax of qname
>  if (columnPosition == 0 || columnPosition == name.length() - 1)
>  throw new ValidationException("Invalid qname '" + name + "'",
> (LocationData) element.getData());
>
>  if (columnPosition == -1 && namespace == null) {
>  // Simple name
>  return new QName(name);
>  } else if (columnPosition != -1 && namespace == null) {
>  // Qualified name using namespace declaration in context
>  String prefix = name.substring(0, columnPosition);
>  String namespaceFromContext = (String)
> Dom4jUtils.getNamespaceContext(element).get(prefix);
>  if (namespaceFromContext == null)
>  throw new ValidationException("No namespace declared for prefix '" + prefix
> + "'",
>  (LocationData) element.getData());
>  return new QName(name.substring(columnPosition + 1), new
> org.dom4j.Namespace(prefix, namespaceFromContext));
>  } else if (columnPosition == -1 && namespace != null) {
>  // Non-qualified name with namespace declaration
>  return new QName(name, new org.dom4j.Namespace("", namespace));
>  } else if (columnPosition != -1 && namespace != null) {
>  // Qualified name using namespace specified
>  return new QName(name.substring(columnPosition + 1),
>  new org.dom4j.Namespace(name.substring(0, columnPosition), namespace));
>  } else {
>  // This can't happen
>  throw new OXFException("Invalid state");
>  }
>  }
> }
>
>
>
> --
> You receive this message as a subscriber of the [hidden email]
> mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>
>
>
> --
> Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/
>
>
>  ________________________________
>
>
> --
> You receive this message as a subscriber of the [hidden email]
> mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>  --
> -----------------------
> oliver charlet
> software development
>
> 11-041 Olsztyn, Poland
>
> [hidden email]
> -----------------------
>
>
> --
> You receive this message as a subscriber of the [hidden email]
> mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>

--
Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: xupdate (2)

Erik Bruchez
Administrator
In reply to this post by Oliver Charlet
Oliver Charlet wrote:

> I didn't know about sax not supporting comments.

Just a precision: SAX does support comments, but not the ContentHandler
interface which we are currently exclusively using in pipelines.
Arguably, that's a bug in the pipeline engine, since in order to provide
full XML Infoset information we should be able to deal with comments.

-Erik



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: xupdate (2) and new problem

Oliver Charlet
ok, but I think we should forget about the xupdate comment for now, since I am the only one that ever mentioned it...

But I have a more basic problem to solve and my knowledge leaves me at this point:

What I do is collecting arbitrary XML documents in a "master" xml document. Later I take parts of that master and serialize them to files.
One example of the content is a page-flow.xpl file. Now the problem are the namespaces. The page-flow.xpl contains the oxf:
namespace for the processor name attribute. When I copy the content into the master document, the master's root element takes over the
namespaces and I can see all of them in a debug output. But when I than extract the same part (of the page-flow.xpl) and serialize it,
the oxf namespace is lost, I suppose because there is no element using it. Now, is this a bug in the serializer or regular behaviour?
How could I solve that problem? Is it possible to tell the serializer to explicitly create / use a certain namespace?
Thanks for any ideas.
:oliver

Erik Bruchez schrieb:
Oliver Charlet wrote:

I didn't know about sax not supporting comments.

Just a precision: SAX does support comments, but not the ContentHandler interface which we are currently exclusively using in pipelines. Arguably, that's a bug in the pipeline engine, since in order to provide full XML Infoset information we should be able to deal with comments.

-Erik


-- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: [hidden email] For general help: [hidden email] ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

-- 
-----------------------
oliver charlet
software development

11-041 Olsztyn, Poland

[hidden email]
-----------------------


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: xupdate (2) and new problem

Alessandro  Vernet
Administrator
Hi Olivier,

How are you extracting the sub-documents from the master document? Are
you using XSLT, or XUpdate, or something else.

Alex

On 12/3/05, Oliver Charlet <[hidden email]> wrote:

>  ok, but I think we should forget about the xupdate comment for now, since I
> am the only one that ever mentioned it...
>
>  But I have a more basic problem to solve and my knowledge leaves me at this
> point:
>
>  What I do is collecting arbitrary XML documents in a "master" xml document.
> Later I take parts of that master and serialize them to files.
>  One example of the content is a page-flow.xpl file. Now the problem are the
> namespaces. The page-flow.xpl contains the oxf:
>  namespace for the processor name attribute. When I copy the content into
> the master document, the master's root element takes over the
>  namespaces and I can see all of them in a debug output. But when I than
> extract the same part (of the page-flow.xpl) and serialize it,
>  the oxf namespace is lost, I suppose because there is no element using it.
> Now, is this a bug in the serializer or regular behaviour?
>  How could I solve that problem? Is it possible to tell the serializer to
> explicitly create / use a certain namespace?
>  Thanks for any ideas.
>  :oliver
>
>  Erik Bruchez schrieb:
> Oliver Charlet wrote:
>
>
> I didn't know about sax not supporting comments.
>
>  Just a precision: SAX does support comments, but not the ContentHandler
> interface which we are currently exclusively using in pipelines. Arguably,
> that's a bug in the pipeline engine, since in order to provide full XML
> Infoset information we should be able to deal with comments.
>
>  -Erik
>
>  ________________________________
>
>
> --
> You receive this message as a subscriber of the [hidden email]
> mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>  --
> -----------------------
> oliver charlet
> software development
>
> 11-041 Olsztyn, Poland
>
> [hidden email]
> -----------------------
>
>
> --
> You receive this message as a subscriber of the [hidden email]
> mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>

--
Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: xupdate (2) and new problem

Oliver Charlet
Hi Alex,

I am using XSLT to extract and shuffle the data into a file-serializer.
thanks for any hints.
:olli

Alessandro Vernet schrieb:
Hi Olivier,

How are you extracting the sub-documents from the master document? Are
you using XSLT, or XUpdate, or something else.

Alex

On 12/3/05, Oliver Charlet [hidden email] wrote:
  
 ok, but I think we should forget about the xupdate comment for now, since I
am the only one that ever mentioned it...

 But I have a more basic problem to solve and my knowledge leaves me at this
point:

 What I do is collecting arbitrary XML documents in a "master" xml document.
Later I take parts of that master and serialize them to files.
 One example of the content is a page-flow.xpl file. Now the problem are the
namespaces. The page-flow.xpl contains the oxf:
 namespace for the processor name attribute. When I copy the content into
the master document, the master's root element takes over the
 namespaces and I can see all of them in a debug output. But when I than
extract the same part (of the page-flow.xpl) and serialize it,
 the oxf namespace is lost, I suppose because there is no element using it.
Now, is this a bug in the serializer or regular behaviour?
 How could I solve that problem? Is it possible to tell the serializer to
explicitly create / use a certain namespace?
 Thanks for any ideas.
 :oliver

 Erik Bruchez schrieb:
Oliver Charlet wrote:


I didn't know about sax not supporting comments.

 Just a precision: SAX does support comments, but not the ContentHandler
interface which we are currently exclusively using in pipelines. Arguably,
that's a bug in the pipeline engine, since in order to provide full XML
Infoset information we should be able to deal with comments.

 -Erik

 ________________________________


--
You receive this message as a subscriber of the [hidden email]
mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws


 --
-----------------------
oliver charlet
software development

11-041 Olsztyn, Poland

[hidden email]
-----------------------


--
You receive this message as a subscriber of the [hidden email]
mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



    


--
Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/

  

-- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: [hidden email] For general help: [hidden email] ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

-- 
-----------------------
oliver charlet
software development

11-041 Olsztyn, Poland

[hidden email]
-----------------------


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: xupdate (2) and new problem

Oliver Charlet
In reply to this post by Alessandro Vernet
Hi there,

I am stil at the problem regarding the oxf:  / http://www.orbeon.com/oxf/processors namespace.
It is, as I see it only used for the definition of the processor names. I tried to find a specification
for using namespaces, or rather qualified names inside attribute values, but I couldn't.
So please somebody explain to me, in which way this is used in orbeon.

Thanks a lot.
:oliver

Alessandro Vernet schrieb:
Hi Olivier,

How are you extracting the sub-documents from the master document? Are
you using XSLT, or XUpdate, or something else.

Alex

On 12/3/05, Oliver Charlet [hidden email] wrote:
  
 ok, but I think we should forget about the xupdate comment for now, since I
am the only one that ever mentioned it...

 But I have a more basic problem to solve and my knowledge leaves me at this
point:

 What I do is collecting arbitrary XML documents in a "master" xml document.
Later I take parts of that master and serialize them to files.
 One example of the content is a page-flow.xpl file. Now the problem are the
namespaces. The page-flow.xpl contains the oxf:
 namespace for the processor name attribute. When I copy the content into
the master document, the master's root element takes over the
 namespaces and I can see all of them in a debug output. But when I than
extract the same part (of the page-flow.xpl) and serialize it,
 the oxf namespace is lost, I suppose because there is no element using it.
Now, is this a bug in the serializer or regular behaviour?
 How could I solve that problem? Is it possible to tell the serializer to
explicitly create / use a certain namespace?
 Thanks for any ideas.
 :oliver

 Erik Bruchez schrieb:
Oliver Charlet wrote:


I didn't know about sax not supporting comments.

 Just a precision: SAX does support comments, but not the ContentHandler
interface which we are currently exclusively using in pipelines. Arguably,
that's a bug in the pipeline engine, since in order to provide full XML
Infoset information we should be able to deal with comments.

 -Erik

 ________________________________


--
You receive this message as a subscriber of the [hidden email]
mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws


 --
-----------------------
oliver charlet
software development

11-041 Olsztyn, Poland

[hidden email]
-----------------------


--
You receive this message as a subscriber of the [hidden email]
mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



    


--
Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/

  

-- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: [hidden email] For general help: [hidden email] ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

-- 
-----------------------
oliver charlet
software development

11-041 Olsztyn, Poland

[hidden email]
-----------------------


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: xupdate (2) and new problem

Erik Bruchez
Administrator
Oliver,

Just in case, we have a page about namespaces here, which is handy to
see what namespace is used for what purpose in OPS:

   http://www.orbeon.com/ops/doc/reference-xml-namespaces

As to how qualified names are used in attribute values, well, if an
attribute value is a QName, like in the case of an XPL processor name
("oxf:xslt"), then a mapping of the prefix to a namespace URI must
simply be in scope on the element containing the attribute. I am not
sure this answers your question. But it is true that this way you cannot
see for sure whether the "oxf" prefix mapping is used, unless you do now
for a fact that certain attributes contain QNames.

(Note that this use should not be confused with the "oxf:" protcol used
to load resources from the resource manager, e.g. "oxf:/my/file.xml".)

Now your problem is still a little abstract to me, but you should know
that with XSLT you can explicitly create and copy namespace nodes. You
should then be able to explicitly create a namespace for the "oxf"
prefix in your output. But I don't understand why you are having this
problem in the first place.

What serializer are you using? XML or HTML?

-Erik

Oliver Charlet wrote:

> Hi there,
>
> I am stil at the problem regarding the oxf:  /
> http://www.orbeon.com/oxf/processors namespace.
> It is, as I see it only used for the definition of the processor names.
> I tried to find a specification
> for using namespaces, or rather qualified names inside attribute values,
> but I couldn't.
> So please somebody explain to me, in which way this is used in orbeon.
>
> Thanks a lot.
> :oliver
>
> Alessandro Vernet schrieb:
>
>>Hi Olivier,
>>
>>How are you extracting the sub-documents from the master document? Are
>>you using XSLT, or XUpdate, or something else.
>>
>>Alex
>>
>>On 12/3/05, Oliver Charlet <[hidden email]> wrote:
>>  
>>
>>> ok, but I think we should forget about the xupdate comment for now, since I
>>>am the only one that ever mentioned it...
>>>
>>> But I have a more basic problem to solve and my knowledge leaves me at this
>>>point:
>>>
>>> What I do is collecting arbitrary XML documents in a "master" xml document.
>>>Later I take parts of that master and serialize them to files.
>>> One example of the content is a page-flow.xpl file. Now the problem are the
>>>namespaces. The page-flow.xpl contains the oxf:
>>> namespace for the processor name attribute. When I copy the content into
>>>the master document, the master's root element takes over the
>>> namespaces and I can see all of them in a debug output. But when I than
>>>extract the same part (of the page-flow.xpl) and serialize it,
>>> the oxf namespace is lost, I suppose because there is no element using it.
>>>Now, is this a bug in the serializer or regular behaviour?
>>> How could I solve that problem? Is it possible to tell the serializer to
>>>explicitly create / use a certain namespace?
>>> Thanks for any ideas.
>>> :oliver
>>>
>>> Erik Bruchez schrieb:
>>>Oliver Charlet wrote:
>>>
>>>
>>>I didn't know about sax not supporting comments.
>>>
>>> Just a precision: SAX does support comments, but not the ContentHandler
>>>interface which we are currently exclusively using in pipelines. Arguably,
>>>that's a bug in the pipeline engine, since in order to provide full XML
>>>Infoset information we should be able to deal with comments.
>>>
>>> -Erik


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: xupdate (2) and new problem

Oliver Charlet
are you referring to the copy / copy-of tags, that allow explicit namespace behaviour? AFAIK there are no explicit commands in XSLT to create namespace nodes. !?

Erik Bruchez schrieb:
Oliver,

Just in case, we have a page about namespaces here, which is handy to see what namespace is used for what purpose in OPS:

  http://www.orbeon.com/ops/doc/reference-xml-namespaces

As to how qualified names are used in attribute values, well, if an attribute value is a QName, like in the case of an XPL processor name ("oxf:xslt"), then a mapping of the prefix to a namespace URI must simply be in scope on the element containing the attribute. I am not sure this answers your question. But it is true that this way you cannot see for sure whether the "oxf" prefix mapping is used, unless you do now for a fact that certain attributes contain QNames.

(Note that this use should not be confused with the "oxf:" protcol used to load resources from the resource manager, e.g. "oxf:/my/file.xml".)

Now your problem is still a little abstract to me, but you should know that with XSLT you can explicitly create and copy namespace nodes. You should then be able to explicitly create a namespace for the "oxf" prefix in your output. But I don't understand why you are having this problem in the first place.

What serializer are you using? XML or HTML?

-Erik

Oliver Charlet wrote:
Hi there,

I am stil at the problem regarding the oxf:  / http://www.orbeon.com/oxf/processors namespace.
It is, as I see it only used for the definition of the processor names. I tried to find a specification
for using namespaces, or rather qualified names inside attribute values, but I couldn't.
So please somebody explain to me, in which way this is used in orbeon.

Thanks a lot.
:oliver

Alessandro Vernet schrieb:

Hi Olivier,

How are you extracting the sub-documents from the master document? Are
you using XSLT, or XUpdate, or something else.

Alex

On 12/3/05, Oliver Charlet [hidden email] wrote:
 

ok, but I think we should forget about the xupdate comment for now, since I
am the only one that ever mentioned it...

But I have a more basic problem to solve and my knowledge leaves me at this
point:

What I do is collecting arbitrary XML documents in a "master" xml document.
Later I take parts of that master and serialize them to files.
One example of the content is a page-flow.xpl file. Now the problem are the
namespaces. The page-flow.xpl contains the oxf:
namespace for the processor name attribute. When I copy the content into
the master document, the master's root element takes over the
namespaces and I can see all of them in a debug output. But when I than
extract the same part (of the page-flow.xpl) and serialize it,
the oxf namespace is lost, I suppose because there is no element using it.
Now, is this a bug in the serializer or regular behaviour?
How could I solve that problem? Is it possible to tell the serializer to
explicitly create / use a certain namespace?
Thanks for any ideas.
:oliver

Erik Bruchez schrieb:
Oliver Charlet wrote:


I didn't know about sax not supporting comments.

Just a precision: SAX does support comments, but not the ContentHandler
interface which we are currently exclusively using in pipelines. Arguably,
that's a bug in the pipeline engine, since in order to provide full XML
Infoset information we should be able to deal with comments.

-Erik


-- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: [hidden email] For general help: [hidden email] ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

-- 
-----------------------
oliver charlet
software development

11-041 Olsztyn, Poland

[hidden email]
-----------------------


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: xupdate (2) and new problem

Erik Bruchez
Administrator
You can manipulate existing namespace nodes using the namespace:: axis,
for example <xsl:copy-of select="namespace::node()"/>. With XSLT 2.0,
you can also use xsl:namespace to create namespace nodes:

http://www.w3.org/TR/2005/CR-xslt20-20051103/#element-namespace

-Erik

Oliver Charlet wrote:

> are you referring to the copy / copy-of tags, that allow explicit
> namespace behaviour? AFAIK there are no explicit commands in XSLT to
> create namespace nodes. !?
>
> Erik Bruchez schrieb:
>
>> Oliver,
>>
>> Just in case, we have a page about namespaces here, which is handy to
>> see what namespace is used for what purpose in OPS:
>>
>>   http://www.orbeon.com/ops/doc/reference-xml-namespaces
>>
>> As to how qualified names are used in attribute values, well, if an
>> attribute value is a QName, like in the case of an XPL processor name
>> ("oxf:xslt"), then a mapping of the prefix to a namespace URI must
>> simply be in scope on the element containing the attribute. I am not
>> sure this answers your question. But it is true that this way you
>> cannot see for sure whether the "oxf" prefix mapping is used, unless
>> you do now for a fact that certain attributes contain QNames.
>>
>> (Note that this use should not be confused with the "oxf:" protcol
>> used to load resources from the resource manager, e.g.
>> "oxf:/my/file.xml".)
>>
>> Now your problem is still a little abstract to me, but you should know
>> that with XSLT you can explicitly create and copy namespace nodes. You
>> should then be able to explicitly create a namespace for the "oxf"
>> prefix in your output. But I don't understand why you are having this
>> problem in the first place.
>>
>> What serializer are you using? XML or HTML?
>>
>> -Erik
>>
>> Oliver Charlet wrote:
>>
>>> Hi there,
>>>
>>> I am stil at the problem regarding the oxf:  /
>>> http://www.orbeon.com/oxf/processors namespace.
>>> It is, as I see it only used for the definition of the processor
>>> names. I tried to find a specification
>>> for using namespaces, or rather qualified names inside attribute
>>> values, but I couldn't.
>>> So please somebody explain to me, in which way this is used in orbeon.
>>>
>>> Thanks a lot.
>>> :oliver
>>>
>>> Alessandro Vernet schrieb:
>>>
>>>> Hi Olivier,
>>>>
>>>> How are you extracting the sub-documents from the master document? Are
>>>> you using XSLT, or XUpdate, or something else.
>>>>
>>>> Alex
>>>>
>>>> On 12/3/05, Oliver Charlet <[hidden email]> wrote:
>>>>  
>>>>
>>>>> ok, but I think we should forget about the xupdate comment for now,
>>>>> since I
>>>>> am the only one that ever mentioned it...
>>>>>
>>>>> But I have a more basic problem to solve and my knowledge leaves me
>>>>> at this
>>>>> point:
>>>>>
>>>>> What I do is collecting arbitrary XML documents in a "master" xml
>>>>> document.
>>>>> Later I take parts of that master and serialize them to files.
>>>>> One example of the content is a page-flow.xpl file. Now the problem
>>>>> are the
>>>>> namespaces. The page-flow.xpl contains the oxf:
>>>>> namespace for the processor name attribute. When I copy the content
>>>>> into
>>>>> the master document, the master's root element takes over the
>>>>> namespaces and I can see all of them in a debug output. But when I
>>>>> than
>>>>> extract the same part (of the page-flow.xpl) and serialize it,
>>>>> the oxf namespace is lost, I suppose because there is no element
>>>>> using it.
>>>>> Now, is this a bug in the serializer or regular behaviour?
>>>>> How could I solve that problem? Is it possible to tell the
>>>>> serializer to
>>>>> explicitly create / use a certain namespace?
>>>>> Thanks for any ideas.
>>>>> :oliver
>>>>>
>>>>> Erik Bruchez schrieb:
>>>>> Oliver Charlet wrote:
>>>>>
>>>>>
>>>>> I didn't know about sax not supporting comments.
>>>>>
>>>>> Just a precision: SAX does support comments, but not the
>>>>> ContentHandler
>>>>> interface which we are currently exclusively using in pipelines.
>>>>> Arguably,
>>>>> that's a bug in the pipeline engine, since in order to provide full
>>>>> XML
>>>>> Infoset information we should be able to deal with comments.
>>>>>
>>>>> -Erik
>>>>
>>
>>------------------------------------------------------------------------
>>
>>
>>--
>>You receive this message as a subscriber of the [hidden email] mailing list.
>>To unsubscribe: mailto:[hidden email]
>>For general help: mailto:[hidden email]?subject=help
>>ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>>  
>>
>
> --
> -----------------------
> oliver charlet
> software development
>
> 11-041 Olsztyn, Poland
>
> [hidden email]
> -----------------------
>
>
> ------------------------------------------------------------------------
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: xupdate (2) and new problem

Oliver Charlet
ahh! bingo. I think I got it now. I didn't think so far as XPath - of course - being part of XSLTs.
I will try to use that.
I got the problems, because I actually generate a complete ops application from within another
ops generator application. And the fun begins, if I use XSLT to generate a page-flow file.
It seems to me, that the transformer erases the oxf: namespace, because there actually is neither
an element nor an attribute that uses the prefix. Obviously any QName values in attributes are not considered
by the processor as being relevant. I am not sure, wether that is correct or not.
But I have to add the oxf: namespace explicitly when doing so. Meanwhile I went another way, avoiding
the namespace problem.

But many thanks for your hints again.

And you should really here my joyfull shouts while developing with OPS. It is even much better than
Lego and that means a lot (not only to me ;-) ). You gave us a very nice tool and for that you deserve
some homages.
:oliver

Erik Bruchez schrieb:
You can manipulate existing namespace nodes using the namespace:: axis, for example <xsl:copy-of select="namespace::node()"/>. With XSLT 2.0, you can also use xsl:namespace to create namespace nodes:

http://www.w3.org/TR/2005/CR-xslt20-20051103/#element-namespace

-Erik

Oliver Charlet wrote:
are you referring to the copy / copy-of tags, that allow explicit namespace behaviour? AFAIK there are no explicit commands in XSLT to create namespace nodes. !?

Erik Bruchez schrieb:

Oliver,

Just in case, we have a page about namespaces here, which is handy to see what namespace is used for what purpose in OPS:

  http://www.orbeon.com/ops/doc/reference-xml-namespaces

As to how qualified names are used in attribute values, well, if an attribute value is a QName, like in the case of an XPL processor name ("oxf:xslt"), then a mapping of the prefix to a namespace URI must simply be in scope on the element containing the attribute. I am not sure this answers your question. But it is true that this way you cannot see for sure whether the "oxf" prefix mapping is used, unless you do now for a fact that certain attributes contain QNames.

(Note that this use should not be confused with the "oxf:" protcol used to load resources from the resource manager, e.g. "oxf:/my/file.xml".)

Now your problem is still a little abstract to me, but you should know that with XSLT you can explicitly create and copy namespace nodes. You should then be able to explicitly create a namespace for the "oxf" prefix in your output. But I don't understand why you are having this problem in the first place.

What serializer are you using? XML or HTML?

-Erik

Oliver Charlet wrote:

Hi there,

I am stil at the problem regarding the oxf:  / http://www.orbeon.com/oxf/processors namespace.
It is, as I see it only used for the definition of the processor names. I tried to find a specification
for using namespaces, or rather qualified names inside attribute values, but I couldn't.
So please somebody explain to me, in which way this is used in orbeon.

Thanks a lot.
:oliver

Alessandro Vernet schrieb:

Hi Olivier,

How are you extracting the sub-documents from the master document? Are
you using XSLT, or XUpdate, or something else.

Alex

On 12/3/05, Oliver Charlet [hidden email] wrote:
 

ok, but I think we should forget about the xupdate comment for now, since I
am the only one that ever mentioned it...

But I have a more basic problem to solve and my knowledge leaves me at this
point:

What I do is collecting arbitrary XML documents in a "master" xml document.
Later I take parts of that master and serialize them to files.
One example of the content is a page-flow.xpl file. Now the problem are the
namespaces. The page-flow.xpl contains the oxf:
namespace for the processor name attribute. When I copy the content into
the master document, the master's root element takes over the
namespaces and I can see all of them in a debug output. But when I than
extract the same part (of the page-flow.xpl) and serialize it,
the oxf namespace is lost, I suppose because there is no element using it.
Now, is this a bug in the serializer or regular behaviour?
How could I solve that problem? Is it possible to tell the serializer to
explicitly create / use a certain namespace?
Thanks for any ideas.
:oliver

Erik Bruchez schrieb:
Oliver Charlet wrote:


I didn't know about sax not supporting comments.

Just a precision: SAX does support comments, but not the ContentHandler
interface which we are currently exclusively using in pipelines. Arguably,
that's a bug in the pipeline engine, since in order to provide full XML
Infoset information we should be able to deal with comments.

-Erik


------------------------------------------------------------------------


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
 


-- 
-----------------------
oliver charlet
software development

11-041 Olsztyn, Poland

[hidden email]
-----------------------


------------------------------------------------------------------------


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



-- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: [hidden email] For general help: [hidden email] ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

-- 
-----------------------
oliver charlet
software development

11-041 Olsztyn, Poland

[hidden email]
-----------------------


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: xupdate (2) and new problem

Erik Bruchez
Administrator
Oliver Charlet wrote:

> ahh! bingo. I think I got it now. I didn't think so far as XPath - of
> course - being part of XSLTs.
> I will try to use that.
> I got the problems, because I actually generate a complete ops
> application from within another
> ops generator application. And the fun begins, if I use XSLT to generate
> a page-flow file.
> It seems to me, that the transformer erases the oxf: namespace, because
> there actually is neither
> an element nor an attribute that uses the prefix. Obviously any QName
> values in attributes are not considered
> by the processor as being relevant. I am not sure, wether that is
> correct or not.
> But I have to add the oxf: namespace explicitly when doing so. Meanwhile
> I went another way, avoiding
> the namespace problem.
>
> But many thanks for your hints again.
>
> And you should really here my joyfull shouts while developing with OPS.
> It is even much better than
> Lego and that means a lot (not only to me ;-) ). You gave us a very nice
> tool and for that you deserve
> some homages.
Thanks :-)

-Erik



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws