Adding an invisible document name in XSLT or HTML

I have this XSLT document that has a file name. However for archiving purposes we want the file name to be displayed somewhere else within the code.

Now I used to do this like this:

<xsl:stylesheet version="1.0" 

However we want to get rid of this solution due to new working methods. Now I was wondering if I could place this (literally just the word DOCUMENTNAME) somewhere within the XSL or within the HTML wrapped within it, in a way that it is not visible.

We add this code to a database, through a validator that looks for the documentname and checks for a match. And as only the contents of the code is placed on the database its easier to check back from the database what documentname was uploaded. However this documentname should not be visible in an HTML output.

Remove Node from XML file

I would like to remove CommentsCorrections node from my xml file. I used the ElementTree XML API for removing the node. I don’t know why my python code is not working, following are examples of python and xml.


import xml.etree.ElementTree as ET 
tree = ET.parse("pubmed_result.xml")
root = tree.getroot()
for CommentsCorrections in root.findall('CommentsCorrections'):


  <CommentsCorrections RefType="Cites">
    <RefSource>Clin Infect Dis. 2005 Nov 1;41(9):1254-60</RefSource>
    <PMID Version="1">16206099</PMID>
  <CommentsCorrections RefType="Cites">
    <RefSource>J Antimicrob Chemother. 1998 Jun;41 Suppl D:7-11</RefSource>
    <PMID Version="1">9688447</PMID>
  <CommentsCorrections RefType="Cites">
    <RefSource>J Antimicrob Chemother. 2008 Mar;61(3):721-8</RefSource>
    <PMID Version="1">18218645</PMID>
  <CommentsCorrections RefType="Cites">
    <RefSource>Infection. 1987;15 Suppl 5:S248-53</RefSource>
    <PMID Version="1">3325435</PMID>
  <CommentsCorrections RefType="Cites">
    <RefSource>N Engl J Med. 2005 Sep 8;353(10):988-98</RefSource>
    <PMID Version="1">16148284</PMID>

How to return xml data in postgresql

I am working on postgresql function where i want to return a xml.

    ws_queue_array character varying DEFAULT NULL::character(1),
    OUT ws_out_xml_data xml)
          RETURNS xml

I am creating an xml using xml function in postgreql but I am not sure how will I return that xml.

SELECT  XMLELEMENT (NAME "name",                 
                   XMLAGG (XMLELEMENT(NAME "var1",                           
                             XMLATTRIBUTES (                                    
                          c_name        AS "c name",                         
                          c_id  AS "c ID"))                         
                     ORDER BY c_id ASC))              
                        INTO OUT_XML_DATA;

How do i return this OUT_XML_DATA?

Alpakka : how to deserialize xml to objects – Is there a more concise pattern for deserializers?

I have complex XML data (it might contain a lot of data and could have more than 15GB) which has a sophisticated nature with a deep structure. We need stream processing for our huge XML. Using the new Alpakka library is our first choice since it is a promising solution.

There are outdated threads on scala-xml serialization and other Scala libraries, but we need to process huge amounts of XML as event streams.

In order to simplify things let’s consider that we have a PurchaseOrder (XML comes from this page).

<?xml version="1.0"?>  
<PurchaseOrder PurchaseOrderNumber="99503" OrderDate="1999-10-20">  
  <Address Type="Shipping">  
    <Name>Ellen Adams</Name>  
    <Street>123 Maple Street</Street>  
    <City>Mill Valley</City>  
  <Address Type="Billing">  
    <Name>Tai Yee</Name>  
    <Street>8 Oak Avenue</Street>  
    <City>Old Town</City>  
  <DeliveryNotes>Please leave packages in shed by driveway.</DeliveryNotes>  
    <Item PartNumber="872-AA">  
      <Comment>Confirm this is electric</Comment>  
    <Item PartNumber="926-AA">  
      <ProductName>Baby Monitor</ProductName>  

I am trying to stream all Item‘s from XML and deserialize them. Be aware of fact that, the same tags might appear on the different levels.
Moreover, the elements/attributes inside Item can appear in arbitrary order.
An approach, which I see (mostly based on Alpakka’s XmlProcessingTest – does anyone can suggest better references?), might look like the following:

import{Characters, EndElement, ParseEvent, StartElement}
import{ActorMaterializer, IOResult}
import scala.collection.mutable
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
import akka.util.ByteString

import{EndElement, ParseEvent, StartElement}

import scala.collection.mutable

trait Builder[T] {
  def build(): T

case class Item(partNumber: String)

object Item {
  def apply(builder: ItemBuilder,
            path: mutable.Stack[String]): PartialFunction[ParseEvent, Unit] = {
    case elem @ StartElement("Item", _, _, _, _) =>
      val partNumber = elem.findAttribute("PartNumber").map(_.value).getOrElse("")
      builder.partNumber = partNumber
    case EndElement("Item") =>

class ItemBuilder() extends Builder[Item] {
  var partNumber = ""

  override def build(): Item =
      partNumber = partNumber

  def reset(): Unit = {
    partNumber = ""

implicit val system = ActorSystem()
implicit val mat = ActorMaterializer()

val path: mutable.Stack[String] = new mutable.Stack[String]()

val xml =
  """<PurchaseOrder PurchaseOrderNumber="99503" OrderDate="1999-10-20">
    |<Address Type="Shipping">
    |  <Name>Ellen Adams</Name>
    |  <Street>123 Maple Street</Street>
    |  <City>Mill Valley</City>
    |  <State>CA</State>
    |  <Zip>10999</Zip>
    |  <Country>USA</Country>
    |<Address Type="Billing">
    |  <Name>Tai Yee</Name>
    |  <Street>8 Oak Avenue</Street>
    |  <City>Old Town</City>
    |  <State>PA</State>
    |  <Zip>95819</Zip>
    |  <Country>USA</Country>
    |<DeliveryNotes>Please leave packages in shed by driveway.</DeliveryNotes>
    |  <Item PartNumber="872-AA">
    |    <ProductName>Lawnmower</ProductName>
    |    <Quantity>1</Quantity>
    |    <USPrice>148.95</USPrice>
    |    <Comment>Confirm this is electric</Comment>
    |  </Item>
    |  <Item PartNumber="926-AA">
    |    <ProductName>Baby Monitor</ProductName>
    |    <Quantity>2</Quantity>
    |    <USPrice>39.98</USPrice>
    |    <ShipDate>1999-05-21</ShipDate>
    |  </Item>

val documentStream = Source.single(xml)

val builder = new ItemBuilder()

val default: PartialFunction[ParseEvent, Unit] = {
  case Characters(any) =>
  case StartElement(localName, _, _, _, _) =>
  case EndElement(localName) =>
  case any =>

val handle: PartialFunction[ParseEvent, Unit] = Item(builder, path) orElse

val source: Source[Item, akka.NotUsed] = documentStream
  .splitWhen(_ match {
    case StartElement("Item", _, _, _, _) =>
    case _ =>
  .fold[ItemBuilder](new ItemBuilder()) {
  case (_, parseEvent) =>
  .map { builder: ItemBuilder =>
    val item =

val resultFuture: Future[Seq[Item]] = source

val result: Seq[Item] = Await.result(resultFuture, 5.seconds)

println("items : " + result)

The example is posted on Scastie

This approach requires a lot of handlers for each tag (val handle: PartialFunction) which might be error prone and too fragile.

I am wondering how to handle ParseEvent in a more concise way and combine them into the required Item objects. Any suggestion how to avoid a boilerplate code? Is there a more concise pattern for deserializers?

How to run two different animations on recyclerView consecutively?

I have a horizontal recyclerView, I want to animate it (by sliding right and then left) when the activity is first opened.

So I do this in onCreate:

final Animation slideRight = AnimationUtils.loadAnimation(this, R.anim.slide_right);

        final Animation slideLeft = AnimationUtils.loadAnimation(this, R.anim.slide_left);

        RecyclerView recyclerView = findViewById(;

but seems like only the right slide works

here are my anims:

left slide

<set xmlns:android=""
    android:shareInterpolator="false" >

        android:toYDelta="0%" />


right slide

    android:toYDelta="0%" />

what am I doing wrong?

EDIT: how is this related to proposed duplicate?

how to remove or replace specific chars are between two xml tags [linux, python, lxml, sed, awk,…]?

I’m using LXML library in python for XML parsing.

in a XML file, i have some bad characters that lead to below error in python:

lxml.etree.XMLSyntaxError: CharRef

Before opening and fetching the content of XML file in python, I must remove bad chars from two tags:

1: <essid cloaked="true">....</essid> or <essid cloaked="false">....</essid>.

2: <client-manuf>....</client-manuf>

the size of XML file is big. so I want to do it with sed or awk or similar tools.

        <total>20    50</total>
    <wireless-client number="1" type="established" first-time="Thu Feb 15 16:45:43 2018" last-time="Thu Feb 15 16:45:43 2018">
        <client-manuf>SHENZHEN BILIAN ELECTRONIC CO.&#x  ef;&#x  bc;&#x  8c;LTD</client-manuf>
        <essid cloaked="true">&#x   0;&#x   0;&#x   0;&#x   0;&#x   0;</essid>
        <carrier>IEEE 802.11b+</carrier>

I want to remove the bad chars from these tags (client-manuf and essid).

From: <client-manuf>SHENZHEN BILIAN ELECTRONIC CO.&#x ef;&#x bc;&#x 8c;LTD</client-manuf>

To (or this): <client-manuf>SHENZHEN BILIAN ELECTRONIC CO. LTD</client-manuf>

To (or this): <client-manuf>SHENZHEN BILIAN ELECTRONIC CO</client-manuf>


From: <essid cloaked="true">&#x 0;&#x 0;&#x 0;&#x 0;&#x 0;</essid>

From: <essid cloaked="false">&#x 0;&#x WiFi 0;&#x MTN 0;&#x 0;&#x 0;</essid>

To (or this): <essid cloaked="true"></essid>

To (or this): <essid cloaked="true">N/A SSID</essid>

To (or this): <essid cloaked="false">WiFi MTN</essid>

for example, two bad chars:

1: 0;

2: &#x

This is my solution. but it doesn’t work well for my needs:

sed -e '/<essid cloaked="\(true\|false"\)>*.*<\/essid>/ s/\(&#x\|0;\)//g' a.txt

Retrieving the XML data on the basis of time slots (24 slots for a day) and bind it to chart

I am trying to bind the XML data to chart but facing problem while sorting the data on the basis of time slots.

Here is the XML:

<?xml version="1.0" encoding="UTF-8"?> 
     <DateNTime>2018-02-13 02.20.06</DateNTime>
     <DateNTime>2018-02-13 05.20.06</DateNTime> 
     <DateNTime>2018-02-13 04.20.06</DateNTime> 

The value of attribute “xmlns” associated with an element type “beans” must not contain the ‘<' character

Hi sir.

I am a beginner of Spiring and i am trying to develop a CRUD application using Spring MVC and Hibernate, i post my

these are the first lines of my code:

beans xmlns=”a class=”vglnk” href=”” rel=”nofollow”>”
xmlns:xsi=”” xmlns:tx=””
xmlns:mvc=”” xmlns:context=””

Multiple fonts to a single custom TextView

How can we use different styles of Roboto(or any other) font (Roboto-Regular, Roboto-Thin, Roboto-Bold etc) in a single custom TextView.

One of the methods to do this programmatically is described here. But how to achieve this if we want to do change style using XML.

Can this be done using custom attributes like this?

        app:type="thin" />

I don’t want to make different java files for each type. Another method is described here but this has issues regarding memory. Looking for a good solution.

How to allow an XML element to appear anywhere via XSD?

I have the following XML:

    <someChild attr="val" />

      <otherSubChild />

A valid XML Schema for this will be very easy. Now the problem is, my program must support a special element which is evaluated when parsing the file, and leads to conditional substitution of elements.


        <if environment="DEV">
          <someChild attr="val" />
        <if environment="PROD">
          <someChild attr="otherVal" />

          <if environment="DEV">
            <otherSubChild />

I think you get the idea. The thing is, the if element is allowed to appear everywhere in the XML, but at the same time allowed to include any element which is allowed for the element it is put in.

How would I define this in a good way? Currently I am having about 90 types/elements in my XML schema, and it would be really cumbersome to manually edit every single type/element to allow an if element which allows the correct child elements.

Is it possible to make a schema which allows the if element as I described above?